tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Luehe <Jan.Lu...@Sun.COM>
Subject Re: [standard] fmt:message overrides my encoding
Date Wed, 11 Sep 2002 22:00:29 GMT


> All my JSP pages have <%@page contentType='text/html; charset=utf-8'%>
> directive on top and the browser should get them in UTF-8. When I use
> <fmt:message> tags, the encoding is reset to my locale's default
> encoding (which is iso-8859-2 for pl_PL). How can I stop fmt:* tags
> from resetting response encoding?

according to section 8.4 ("Response Encoding") of the JSTL spec, "any
i18n action that establishes a localization context is responsible for
setting the response's locale of its page [...] This is done by
calling method ServletResponse.setLocale() with the locale of the
localization context."

Notice that the Servlet 2.3 and JSP 1.2 specs have been ambiguous with
respect to how/if ServletResponse.setLocale() should affect the
response char encoding of a page that already contains a page
directive with a 'content-type' attribute with a charset component, as
in your example.
JSP 1.2 Errata_a
21.html), Issue 1 ("i18n: Dynamic PAge Character Encoding Clarification")
attempts to resolve this ambiguity, by specifying that a container
must call ServletResponse.setContentType() with the initial content
type before processing the page, and that the content type (and char
encoding) may then be changed dynamically by calling setContentType()
or setLocale(), with the most recent call taking precedence (see
clarification of JSP.3.3: "Dynamic Content Type" in JSP 1.2 Errata_a).

In your example, the container determines the char encoding associated
with the "pl" locale to be ISO-8859-2, and uses this charset to
override the charset specified in the page directive. (Tomcat uses 
its "" resource to map a locale to its

JSP 1.2 Errata_a is currently being reconsidered by the Servlet 2.4 and
JSP 2.0 expert groups, with some experts arguing that setLocale() should
always set the response's Content-Language header, but should not override
the response's char encoding that was set using setContentType() or

Hope this answers your question.


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

View raw message