There are approximately 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 so, there will be an exception:
java.lang.IllegalStateException: Cant sendRedirect() after data has committed to the client.
at com.caucho.server.connection.AbstractHttpResponse.sendRedirect(AbstractHttpResponse.java:558)
...
Browser address bar changes after jump
If you want to jump to a different host, after the jump, the statement after this statement will continue to execute, as a new thread, but the operation of the response has no meaning;
If you want to jump to the same host, the statement after this statement completes execution before jumping;
Two. Response.setheader ("Location", "")
Out.flush () is not allowed before this statement, and if so, the page will not jump.
Browser address bar changes after jump
The statement after this statement finishes execution does not jump
Three.
Out.flush () is not allowed before this statement, and if so, 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 only jumps to the current host
The statement after this statement finishes execution does not jump