1、HttpServletRequest.getRequestDispatcher可以不加前面的“/”,可以使用相对路径(也可以加,代表绝对路径了),
2、ServletContext.getRequestDispatcher只允许使用“/”开头的绝对路径。
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ServletContext context = getServletContext();
RequestDispatcher dispatcher = context.getRequestDispatcher("/jsp/login_result.jsp");
dispatcher.forward(request, response);
/*response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", fuck you sister using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();*/
}