Sendredirect
Response.sendredirect ();
According to the logic, the server sends a status code, tells the browser to request a new address again, generally speaking, the browser will use all the parameters just requested again, so the session,request parameters can be obtained. Note: You cannot read with the contents of the Request.setattribute. Because it's not the same request. As shown in the figure
2 forward
(1) Inside the servlet
Request.getrequestdispatcher ("jsp2.jsp"). Forward (request, response);
(2) inside the JSP
<jsp:forward page= "include.jsp"/>
This column more highlights: http://www.bianceng.cn/webkf/JSP/
The page will be the content of page 2, the address bar does not change. Use the content of Request.setattribute to work properly because it is a request forwarding. As shown in figure
3 include
(1) Inside the servlet
Request.getrequestdispatcher ("jsp2.jsp"). Include (request, response);
(2) inside the JSP
<jsp:include page= "include.jsp"/>
The page contains the contents of page 1 and page 2, and the address bar is unchanged.
Using Request.setattribute content, you can get it normally.