There are about three ways to jump using JSPs:
1. Response.sendredirect ();
2. Response.setheader ("Location", "" ");
3.
Some of the following rules have been tested:
I. Response.sendredirect ()
Out.flush () is not allowed before this statement, and if there is Out.flush (), 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;
Two. Response.setheader ("Location", "" ")
Out.flush () is not allowed before this statement, and if there is Out.flush (), the page does not jump.
Change of browser address bar after jump
The statement following this statement will not jump after execution completes
Three.
Out.flush () is not allowed before this statement, and if it does, there will be an exception:
Java.lang.IllegalStateException:forward () not allowed after buffer has committed.
At Com.caucho.server.webapp.RequestDispatcherImpl.forward (requestdispatcherimpl.java:134)
At Com.caucho.server.webapp.RequestDispatcherImpl.forward (requestdispatcherimpl.java:101)
At Com.caucho.jsp.PageContextImpl.forward (pagecontextimpl.java:836)
...
The browser address bar does not change after the jump, but can only jump to the current host under
The statement following this statement will not jump after execution completes
This article transferred from ☆★ Black and white front ★☆-www.hackline.net reprint Please specify the source, infringement must investigate!
Original link: http://www.hackline.net/a/Special/wzjs/2009/1004/873.html
(GO) jsp three kinds of page jump method comparison