JSP jumps to the servlet:
1.<jsp:forward page= "url" ></jsp:forward> note that the URL here cannot directly write your servlet name, but to fill out the url-pattern of the servlet in Web.xml, namely "/xxxservlet" form. There are slashes, slashes, staves. In addition, this way directly jumped away, in the servlet write jump back to the original page of the statement, will be an error java.io.IOException:Stream closed.
2.<jsp:include page= "url" ><jsp:param name= "xx" value= "xx"/></jsp:include> ditto, the URL has a slash. The advantage of this approach is that the servlet does not have to write a jump statement and will automatically return to the original page because it is a dynamic include File command. In addition, this method can also pass multiple parameters, you know.
3. Use JavaScript. such as <script type= "Text/javascript" >window.location= "Xxxservlet" </script>
Servlet jumps to JSP
1.response.sendredirect ("URL") the browser address bar changes after the jump. You can jump to any page, not necessarily limited to this web application.
This way to pass the value out, you can only in the URL with parameter or in the session, can not use Request.setattribute to pass.
2.request.getrequestdispatcher ("/a.jsp"). Dispatcher. Forward (request, response);
The path to a servlet page jump is a relative path. The forward method can only jump to a page in this Web application. The browser address bar will not change after the jump.
Use this way to jump, the value can be used in three ways: URL with Parameter,session,request.setattribute