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