1 sendRedirect
Response. sendRedirect ();
The server sends a status code based on the logic, telling the browser to request a new address. Generally, the browser will use all the parameters in the previous request to request a new address. Therefore, the session and request parameters can be obtained. Note: The content of request. setAttribute cannot be read. Because it is not the same request.
Request. getRequestDispatcher ("jsp2.jsp"). forward (request, response );
(2) In jsp
<Jsp: forward page = "include. jsp"/>
The page will be the content of page 2, and the address bar will not change. The content of request. setAttribute can be used normally because it is request forwarding.
Request. getRequestDispatcher ("jsp2.jsp"). include (request, response );
(2) In jsp
<Jsp: include page = "include. jsp"/>
◆ The page will contain the content of page 1 and page 2 at the same time, and the address bar will remain unchanged.
◆ The content of request. setAttribute can be obtained and used normally.