@WebServlet("/demo2")
public class ServletDemo2 extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("demo2......第一次");
System.out.println("demo2:"+request);
request.getRequestDispatcher("/demo1").forward(request, response);
System.out.println("demo2......第二次");
System.out.println("demo2:"+request);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request,response);
}
}
@WebServlet("/demo1")
public class ServletDemo1 extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("demo1.......");
System.out.println("demo1:"+request);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request,response);
}
}
demo2......第一次
demo2:org.apache.catalina.connector.RequestFacade@4fb8968f
demo1.......
demo1:org.apache.catalina.core.ApplicationHttpRequest@1fdba35b
demo2......第二次
demo2:org.apache.catalina.connector.RequestFacade@4fb8968f