package helloworld;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class DPEAdminServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
ServletContext sc = this.getServletContext();
/*This code will generate a runtime error
*because of the lack of a forward slash before
*the getRequestDispatcher parameter
*/
request.setAttribute("title","hello servlet include");
request.setAttribute("body","servlet include test successfuly!!!");
RequestDispatcher dis = sc.getRequestDispatcher("/menu.html");
if (dis != null){
dis.include(request, response);//包含文件,静态动态均可
//dis.forward(request,respomse);//转发请求
}
}
//Clean up resources
public void destroy() {
}
}