Bug 45609 - contentType=image sometime cause strange character (??) with UTF-8 encoding and throw java.lang.IllegalStateException
Summary: contentType=image sometime cause strange character (??) with UTF-8 encoding a...
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 6.0.13
Hardware: All All
: P2 major (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-10 22:06 UTC by Jirat
Modified: 2008-08-11 08:45 UTC (History)
1 user (show)



Attachments
screenshots and source code to generate the problem (30.68 KB, application/x-zip-compressed)
2008-08-10 22:06 UTC, Jirat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jirat 2008-08-10 22:06:01 UTC
Created attachment 22424 [details]
screenshots and source code to generate the problem

please see screenshots for this problem.

the problem sometime occur if we have 1 jsp that contentType=image/png or image/jpg and that JSP write image to the out stream.
when other jsp call that page many times.  the server throws java.lang.IllegalStateException. and sometime the character encoding is become "?????"


please see attached phone.jsp,  it is the jsp that write image to the output stream and get parameter id=[number].
you can call phone.jsp?id=123 without any problem or Exception.

But if you call it many times (please use testphone.jsp to test).
when you refresh the testphone.jsp page many times.  the UTF-8 encoding become broken and you can see only "????" character.

I tried on both Windows and Unix and it has the same problem.

Here are the error from localhost logs.
Aug 11, 2008 11:35:12 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
	at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
	at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:662)
	at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:325)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)
Comment 1 Mark Thomas 2008-08-11 08:18:24 UTC
We have seen this sort of issue in the past.

Remy looked into it and found that the graphics library was accessing the output stream outside of the service method and it was this that was causing the issue.

I did a search of the archives and found bug 37516 which had the same root cause (although different symptoms) and I am sure there were others.
Comment 2 Jirat 2008-08-11 08:45:13 UTC
Thank you very much,
but then how can we fix this issues?
I already follow your link but it doesn't provide the solution.
I also searched for Java2D or stream or outside service and not found any useful solution.

Best Regards,