About Java upload, download and import report Java.lang.IllegalStateException exception resolution

Source: Internet
Author: User

Java.lang.IllegalStateException Exception resolution

The following error occurred when using Response.sendredirect () recently:
Java.lang.IllegalStateException
Org.apache.catalina.connector.ResponseFacade.sendRedirect (responsefacade.java:423)

After analyzing and viewing the JDK document finally find a solution, add the return statement after the Response.sendredirect () method, as follows:
Response.sendredirect ("login.jsp");
Return

The reason: The Response.sendredirect () method was called two times in the program.



It is clear in the jdk5.0 documentation that there is a possibility of a IllegalStateException exception:

1) Call the Response.sendredirect () method again on the same page.
2) URL error submitted, which is not a valid URL.

Sendredirect
void Sendredirect (java.lang.String location)
Throws Java.io.IOException
Sends a temporary REDIRECT response to the client using the specified redirect location URL.  This method can accept relative URLs; The servlet container must convert the relative URL to a absolute URL before sending the response to the client. If the location is relative without a leading '/' The container interprets it as relative to the current request URI. If the location was relative with a leading '/' The container interprets it as relative to the servlet container root.
If The response have already been committed, this method throws an illegalstateexception. After using this method, the response should is considered to being committed and should not being written to.

Parameters:
Location-the REDIRECT Location URL
Throws:
Java.io.ioexception-if an input or output exception occurs
Java.lang.illegalstateexception-if The response was committed or If a partial URL is given and cannot being converted into A valid URL

About Java upload, download and import report Java.lang.IllegalStateException exception resolution

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.