JSP page jump to the actual combat rules

Source: Internet
Author: User
Tags flush

There are approximately three ways to jump using JSPs:

1 response.sendredirect ();

2. Response.setheader ("Location", "");

3.

has been tested for some of the following rules:

One. Response.sendredirect ()

This statement is not allowed to have out.flus before H (), if there is a out.flush (), there will be an exception:

Java.lang.IllegalStateException:Can ' t Sendredirect () after data has committed to the C Lient.

at Com.caucho.server.connection.AbstractHttpResponse.sendRedirect (abstracthttpresponse.java:558)

... The browser address bar changes after the

Jump

If you want to jump to a different host, after the jump, the statement following this statement will continue to execute as if the new thread was opened, but the operation on response is meaningless;

If you want to jump to the same host, The statement after the execution of this statement does not jump,

Two. Response.setheader ("Location", "")

does not allow Out.flush () before this statement, and if there is Out.flush (), the page does not jump. The browser address bar changes after the

Jump

The statement after the statement is completed is finished before jumping

three.

This statement is not allowed to have Out.flush (), if so, there will be different Often:

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 be skipped until the execution of the statement after the statement after the current host is completed before it jumps
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.