Why do I get java.lang.illegalStateException?

xiaoxiao2021-03-06  41

Why do I get java.lang.illegalStateException?

Thase Are The Most Common REASONS How You Can Get An

Java.lang.illegalStateException:

Calling setBuffersize and content Has been Written. The Response Has Been Committed and you do any of the folload:

Calling ServletResponse.reset () or ServletResponse.resetBuffer () Calling either HttpServletResponse.sendError () or HttpServletResponse.sendRedirect () Calling RequestDispatcher.forward () which includes performing a jsp:. Forward Calling RequestDispatcher.forward () which includes performing a jsp : Forward Remember That if You Call

Forward () or

Sendredirect (), Any Following Lines of Code Will STILL EXECUTE. For Example:

{

...

Response.sendRedirect ("foo.jsp");

// at this Point, you shouth ketbably has return statement Otherwise

// the folowing code will

System.out.println ("After Redirect! By The Way ...");

System.out.println ("Use Commons-Logging or Log4j, Not System.out");

System.out.println ("System.out Is A Bad Practice!");

Response.sendRedirect ("bar.jsp"); / * this will throw an error! * /

}

转载请注明原文地址:https://www.9cbs.com/read-69731.html

New Post(0)