Cause and solution of getoutputstream () has already been called for this response exception in JSP of tomcat6

Source: Internet
Author: User

 

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 #

 

Related Article

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.