I also encountered this problem, so I posted it for your understanding.
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.
Specific reasons:
After JSP is compiled into servlet in Tomcat
There isCode
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.
Call the following two lines of code after the output stream is used:
Out. Clear ();
Out = pagecontext. pushbody ();
Finally, here is an example of the output color Verification Code (such an example is almost everywhere). The following is part of the Code:
ImageIO. Write (image, "Jpeg", OS );
OS. Flush ();
OS. Close ();
OS = NULL;
Response. flushbuffer ();
Out. Clear ();
Out = pagecontext. pushbody ();
Source: http://chenlb.blogjava.net/archive/2007/05/26/104714.html #