Assuming you are using a version of Tomcat 5, you will have to
modify something on the <Connector> to fix this, easily.

If you want request.setCharacterEncoding("UTF-8") to affect the
encoding of GET query parameters (not just POST parameters),
then you must set useBodyEncodingForURI="true" on the <Connector>.
The default value of useBodyEncodingForURI is false for
Tomcat 5, so GET query parameters are assumed to be encoded
according to the URIEncoding attribute setting and
setCharacterEncoding() doesn't effect their encoding.

Cheers,
Larry

> -----Original Message-----
> From: sol myr [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 07, 2006 5:11 AM
> To: users@tomcat.apache.org
> Subject: [tomcat] : request.setCharacterEncoding ("UTF-8") 
> doesn't work ?
> 
> Hi,
>    
>   I'm having a problem with  
> HttpServletRequest.setCharacterEncoding("UTF-8").
>   Basically, tomcat seems to ignore it completely, and assume 
> "latin1" encoding.
>    
>   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" > ).
>    
>   - I can actually see that the browser  sends the data 
> correctly (this is a GET, so I can see the 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