There are several ways to transfer values between Java Web pages
1.form Form pass Parameters
2.url Address bar Pass parameters
3.session
4.cookie
5.application
6. Passing values by hidden fields
7. Pass the value through the JavaBean
8. Request.setattribute ("Strrequest", strrequest);
9.response.setattribute ("name", name) to the next page
response.sendredirect (): working on the user's browser, sengredirect () can be passed with parameters such as Servlet?name=tom to the next page, It can also redirect to a different host sendredirect () to redirect to a JSP file with a frame. The URL of the redirected page appears on the browser address bar after redirection.
11.
1) REDIRECT Mode
Response.sendredirect ("/a.jsp");
The path to the page is a relative path. Sendredirect can jump pages to any page, not necessarily confined to this web application, such as:
Response.sendredirect ("Http://www.jb51.net");
Change the browser address bar after the jump.
This way, if you want to pass the value out, you can only take parameter in the URL or in the session, cannot use Request.setattribute to pass.
2) Forward mode
RequestDispatcher dispatcher = Request.getrequestdispatcher ("/a.jsp");
Dispatcher. Forward (request, response);
The path to the page is a relative path. The forward method can only be redirected to a page in this web App.
The browser address bar does not change after the jump.
Use this method to jump, the value can be used three methods: URL with Parameter,session,request.setattribute
Jsp:
1) response.sendredirect ();
The same way as the servlet's Response.sendredirect ().
Out.flush () is not allowed before this statement, and if it does, there will be an exception:
Java.lang.IllegalStateException:Can ' t Sendredirect () after data have committed to the client.
At Com.caucho.server.connection.AbstractHttpResponse.sendRedirect (abstracthttpresponse.java:558)
...
Change of browser address bar after jump
If you want to jump to a different host, after the jump, the statement after this statement will continue to execute, as if the new thread, but the operation of the response is meaningless;
If you want to jump to the same host, the statement after the statement after the completion of the execution will not jump;
2) Response.setheader ("Location", "");
Out.flush () is not allowed before this statement, and if so, the page does not jump.
Change of browser address bar after jump
The statement following this statement will not jump after execution completes
Ext.: http://www.jb51.net/article/35550.htm
Methods and values of several page jumps in Java servlet