sol myr a écrit :

>Hi,
>   
>  I'm having a problem with  HttpServletRequest.setCharacterEncoding("UTF-8").
>  Basically, tomcat seems to ignore it completely, and assume "latin1" 
> encoding.
>  
>

request.setCharacterEncoding("UTF-8") must be called prior to any 
request.getParameter() call. If your code or any filter or any tomcat valve 
does a call to request.getParameter() or any other method that would trigger 
the decoding of parameter, the query is decoded with default character encoding 
(that is the one sent by browser or the one specified by tomcat connector or 
the platform default encoding, which ever is defined first).

>   
>  Here's the details:
>   
>  - I have an html < form > where user should type data in *Chinese*.
>   
>  - The browser (IE6) knows that the form data should be sent to the server, 
> encoded as  UTF-8  ( this encoding is mentioned in my "content-type" as well 
> as in < from accept-charset="UTF-8" > ).
>  
>
That's the correct way.

>   
>  - I can actually see that the browser  sends the data correctly (this is a 
> GET, so I can see the encoding)... 
>  
>
Does browser send a header with request encoding?

>   
>  - On the servlet size, I write:
>        request.setCharacterEncoding("UTF-8");
>        String p=request.getParameter("name");
>   
>  Unfortunatelly, this simply doesn't work.  Tomcat reads the parameters as if 
> they were "latin1" ... I can extract them by forcefully converting back to 
> utf-8, but it's ugly and not portable...
>   
>  I know you can configure tomcat's < Connector >  to use utf-8, but I really 
> don't want to do it ( client has a standard Tomcat installation, and I'm 
> absolutely not allowed to touch it).
>  Is there any reason why tomcat would ignore my 
> "request.setCharacterEncoding" ? 
>  Am I doing something wrong, or is Tomcat just ignoring the  j2ee spec in 
> this point ?
>   
>  Thanks
>
>               
>---------------------------------
>Brings words and photos together (easily) with
> PhotoMail  - it's free and works with Yahoo! Mail.
>  
>


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

Reply via email to