tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael S├╝dkamp <>
Subject default charset for text/*
Date Mon, 26 Jul 2004 11:34:21 GMT

In our web-app that runs with Tomcat 4.1.29 we set the content-type to "text/xml" in a servlet
that serves an XML file. The XML encoding normally is UTF-8. We observed that special characters
show up wrong in the browser. Packet sniffing revealed that Tomcat changed the content-type
to "text/xml;charset=ISO-8859-1" which was not the case with earlier Tomcat versions.

I looked up the bug database and the mailing list for this behaviour and read that Tomcat
behaves like this for alle "text/*" content types where the charset is mising.

To fix this I can change the mime-type-definition in web.xml to "text/xml;charset=UTF-8" or
add this in my servlet. But If my servlet has to serve ISO-8859-1 XML files that would be
also wrong. Should I parse the resource prior to serving it in order to determine the encoding?

I cannot find the strong requirement to add the default charset in the HTTP spec. I read a
discussion in the list that the JSP spec requires it - but also for a servlet? I think the
charset is added by the Coyote connector so from the connector's point of view servlets and
JSP-servlets are the same.

Doesn't it make sense to omit the default charset for XML files because XML files normally
should carry their encoding in the header? Then the browser could get the encoding from there
as it was done with earlier Tomcat versions.

What is your opionion?

Best Regards


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message