Bug 28347 - Response committed before invocation of service method
Summary: Response committed before invocation of service method
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.0.19
Hardware: PC other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2004-04-12 10:43 UTC by Koen Heene
Modified: 2004-11-16 19:05 UTC (History)
0 users

Application /encoding proving early charset switch and too early response commit (4.67 KB, application/octet-stream)
2004-04-12 10:44 UTC, Koen Heene

Note You need to log in before you can comment on or make changes to this bug.
Description Koen Heene 2004-04-12 10:43:14 UTC

I have provided a sample encoding.war, proving that:

1/ on unpredictable times the default character encoding UTF-8 is switched to 

2/ a response is sometimes committed before the invocation of the _jspService 

This small sample application does the following. The index.jsp contains 400 
frames. The uneven frames request a 

JSP that produces html with the (€) euro character (UTF-8 hex code E282AC). The 
even frames request a Servlet 

that produces an image/png with the euro character. 400 requests are thus 
received by Tomcat. The html is served 

by a JSP Document. The image/png is served by a Servlet test.ImageSender, which 
makes use of javax.imageio. 

Source is provided in WEB-INF/classes/test.

You will notice (check the log files) that 

1/ When Tomcat sends the html with the euro character, the character encoding 
is sometimes ISO-8859-1 instead of 


2/ Sometimes response.isCommitted() returns true before the invocation of the 
service method (the container might 

therefore throw IllegalStateException if we'ld use sendRedirect() or forward()).

My system info:

Microsoft Windows Server 2003 Entreprise Edition
Java 1.4.2_02
Tomcat 5.0.19

Thanks for your reply.

Koen Heene
Contracted trainer at Sun Microsystems Educational Services Belgium
Comment 1 Koen Heene 2004-04-12 10:44:56 UTC
Created attachment 11216 [details]
Application /encoding proving early charset switch and too early response commit
Comment 2 Koen Heene 2004-04-12 10:46:21 UTC
The attachment should be saved as encoding.war
Comment 3 Remy Maucherat 2004-04-12 11:00:42 UTC
The test is *extremely* bad, and will most likely screw up any server.
I am not willing to spend the time investigating this. You should debug this
yourself if you're interested.
Comment 4 Koen Heene 2004-04-12 14:48:39 UTC
I would appreciate why you think it's so dangerous. The Resin engine 3.0.7 
(supporting JSP 2.0 and Servlet 2.4) does this very nicely.
Comment 5 Remy Maucherat 2004-04-12 15:10:09 UTC
Use it then ;)
Comment 6 Koen Heene 2004-04-12 21:27:52 UTC
You are *extremely* helpful.
Comment 7 Remy Maucherat 2004-04-12 21:42:16 UTC
Well, I don't know, you're the one who suggested resin was working, so ... ;)
Comment 8 Koen Heene 2004-04-12 22:02:48 UTC
I did a search on the internet to see how such an arrogant person looks like. 
Your name is all over. Your picture fortunately not.

Comment 9 Remy Maucherat 2004-04-12 22:05:03 UTC
Lol ;)