users@glassfish.java.net

Re: Encoding issues

From: Wolfram Rittmeyer <w.rittmeyer_at_jsptutorial.org>
Date: Tue, 21 Apr 2009 19:53:30 +0200

glassfish_at_javadesktop.org wrote:
> Hi,
>
> I've set up glassfish and deployed a war unto it, and everything seems to be fine. However, after playing around with my application I realized that it didn't handle UTF-8 characters in input well.
>

I do not know about Jetty, but for any encoding other than ISO-8859-1
(which is the default according to the spec if not other encoding has
been specified by the browser) you first have to call the
request.setCharacterEncoding(encodingString) method. In your case
request.setCharacterEncoding("UTF-8").

And this method has to be called before the any data is read from the
request (getParameter() or getReader() calls). I personally use a filter
which of course has to be high up in the filter chain to guarantee this.


--
Wolfram Rittmeyer