users@woodstock.java.net

Re: Encoding bug?

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Thu, 29 Nov 2007 11:29:32 -0500

Sounds like an issue involving HttpServletRequest? Although your page
may use a certain encoding, that doesn't necessarily mean the servlet is
using the same. The browser encodes form data, but I have observed that
page encoding info is not provided with the request. This means that the
servlet may not decode request parameters correctly unless the character
encoding is set. The tricky part is that the encoding must be set prior
to retrieving any request parameters. Once a parameter has been
retrieved, the encoding cannot be set again. And if the character
encoding is not set, the default is to use the encoding the server was
started with. At least, that's how Tomcat implemented it -- not certain
if Glassfish is the same.

    public void setEncoding(FacesContext context) {
        context.getExternalContext().setResponseCharacterEncoding("UTF-8");
    }
      

Dan

Lking wrote:
> I'm not sure whether it's a bug but I figured out some issues working
> with WoodStock, IE6 and special characters such as "á" "à" and so
> on... Most of it appears when doing some AJAX.
>
> I have a textfield and if I enter some value as "são paulo" my value
> change event will send me a new value as "são paulo". This is just
> garbage to me as I can't work with this value in my backing bean.
>
> Working with ListBox and AJAX, if the value to be displayed after an
> AJAX request is something like "são paulo" it won't work in IE.
> Firefox can do it fine, but still has the same issue reported first,
> with textbox.
>
> Am I missing anything here? My JSP is set to ISO-8859-1 encoding.
>
> thanks.