tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Bridges <>
Subject charset encoding bug
Date Tue, 24 Apr 2007 16:25:48 GMT

I originally posted this as a comment to bug 32499,
and was told to send it to the users mailing list.

Bug 32499 was marked as a duplicate of 24970, but it
is not a duplicate.  

Bug 24970 was marked as wont fix, which is
appropriate.  The justification for 24970 being won't
fix is in comment #24 on bug 24970 which reads,

"The servlet spec expert group has decided that all
Servlets that use a Writer (and this includes all
JSPs) must include a charset in the 2.4 servlet spec.
Since Tomcat 4 uses the same connectors as Tomcat 5,
and Tomcat 5 must set the charset, this will certainly
not be fixed."

However the code for bug 32499 does not use a servlet
or a JSP. 

As a test, execute this code in a servlet using Tomcat

HttpServletResponse sresp = ...

this will print,


This bug makes serving xml files particularly
difficult as the charset may be set in the xml
declaration <?xml charset='...' ?>, or by the first
several bytes of the xml file.  Often when serving
xml, you want to set the mime type as application/xml,
and let the client parser determine the charset from
the file contents.

Tracing through the code, it seems this bug stems from
the Response.setLocale(Locale locale) method calling,

In the method setCharacterEncoding(String charset),
there is the line charsetSet=true;



Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message