Cause and solution of getoutputstream () has already been called for this response exception in JSP of tomcat5
In Tomcat 5, this error occurs in JSP. Generally, the output stream is used in JSP (such as the output image verification code and file download ),
The reason is not properly handled.
The specific reason is
After JSP is compiled into servlet in Tomcat
There is such a piece of code
Finally {
If (_ jspxfactory! = NULL) _ jspxfactory. releasepagecontext (_ jspx_page_context );
}
The object used in JSP will be released and response. getwriter () will be called because the method is
Response. getoutputstream () conflict! Therefore, the above exception occurs.
Then, of course, we need to propose a solution, which is actually quite simple (not just as some friends say --
Delete all spaces and carriage return characters in JSP ),
Call the following two lines of code after the output stream is used:
Out. Clear ();
Out = pagecontext. pushbody ();