> -----Original Message-----
> From: Kris Schneider [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 03, 2003 2:07 PM
> To: Tag Libraries Users List; [EMAIL PROTECTED]
> Subject: Re: fmt_rt encoding trouble
> 
> 
> Okay, so by using <fmt_rt:setLocale>, you're effectively 
> calling response.setLocale, which may modify the response 
> content-type's charset. What happens if you do:
> 
> <c:set target="${pageContext.response}"
>        property="contentType"
>        value="text/html;charset=ISO-8859-7"/>
> 

The application I'm working on uses the JSTL <fmt> tags and UTF-8 encoding
as well and we ran into the same problem of the tags resetting the charset
encoding via the call to setLocale.  You cannot rely on setting the content
type or character encoding when using the JSTL tags, since at any point the
response buffer could get committed, in which case whatever charset encoding
was last set will be the "winner".  Instead, you need to prevent the
response.setLocale() method from changing the character set encoding.

The way I worked around the problem was to create a ServletFilter that
intercepts all requests, and replaces the response object with a custom
class that extends HttpServletResponseWrapper.  In my custom class, I set
the encoding of the response to UTF-8, and then override all methods
(setLocale, setContentType, getCharacterEncoding) to prevent the value from
changing from UTF-8.

This seems to work pretty well under Weblogic 6.1 SP5, Tomcat 4.1 and Oracle
9iAS.  

In JSTL 1.1/JSP 2.0, the response encoding issue is addressed much better,
and allows the web.xml file to be used to map locales to character set
encodings explicitly (so the Locale.JAPANESE, can be forced to use UTF-8
rather than Shift_JIS encoding in a container independent fashion).  

All of our resource bundles were encoded as straight ASCII, but had been run
through native2ascii to properly encode any non-ASCII characters to the
appropriate \uxxxx values.  We support several European languages as well as
some Asian languages.

Hope this helps,

Robb

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to