You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by arun kumar <ar...@yahoo.com> on 2010/07/13 18:21:39 UTC

Tomcat and Hex characters

Hello
  I'm facing a problem with which i need some help:

I'm using JBOSS which internally uses Tomcat.
When i send a request to a servlet running inside tomcat with a parameter that is encoded in UTF-8, the parameter's value shows up as ????.
I tried several things like adding URIEncoding=”UTF-8” and useBodyEncodingForURI="true" in the server.xml and writing a filter that sets the encoding to UTF-8 specifically but to no avail.

The only thing that seems to work is if i replace the % in the hex value of the UTF encoded string by %25

Any clues on this problem? What do i have to do to be able to pass hex values of UTF-8 encoded strings that represent characters of foreign languages (like say Chines/Japanese) to my servlet so it is read correctly? Is there some specified way to read it?

Thanks and regards
Arun


      

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat and Hex characters

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com]
> Subject: Re: Tomcat and Hex characters
> 
> When you mention "running under JBOSS", does that mean that there is
> some webserver in front of Tomcat ?

Probably not.  JBoss uses an embedded version of Tomcat as its web server and servlet container.  JBoss itself provides the rest of the Java EE specification function (the bits that Tomcat doesn't do), along with a good set of capabilities beyond that.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: Tomcat and Hex characters

Posted by André Warnier <aw...@ice-sa.com>.
Hi.

Independently of the questions of character set encodings and settings (for that, really 
read the FAQ to which Chuck pointed you), the fact that you wrote this :

...
> The only thing that seems to work is if i replace the % in the hex value of the UTF encoded string by %25
> 

makes me suspect that there are actually /two/ consecutive URL-unescaping stages taking 
place : the first one decodes "%25xy" into "%xy", then the second one decodes %xy into a 
byte belonging to the UTF-8 encoding of one of your Unicode characters.
This is wrong anyway.

When you mention "running under JBOSS", does that mean that there is some webserver in 
front of Tomcat ?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat and Hex characters

Posted by Mitch Claborn <mi...@claborn.net>.
This may help.  If any of the filters in the chain do any kind of read 
to the input stream, then the encoding is fixed from that point on.  I 
had a similar problem with Struts in Tomcat.  I solved it by putting a 
filter in the chain ahead of sturts and calling
   req.setCharacterEncoding("UTF-8");
on the ServletRequest before calling the next filter(s).


Mitch



On 07/13/2010 11:33 AM, Caldarale, Charles R wrote:
>> From: arun kumar [mailto:arunbhat01@yahoo.com]
>> Subject: Tomcat and Hex characters
>>
>> What do i have to do to be able to pass hex values of
>> UTF-8 encoded strings that represent characters of
>> foreign languages (like say Chines/Japanese) to my
>> servlet so it is read correctly?
>
> Start by studying this (it's non-trivial, and it's not clear how running inside JBoss affects it):
> http://wiki.apache.org/tomcat/FAQ/CharacterEncoding
>
> If that doesn't help, come back to the list and tell us what exact Tomcat version you're using, along with the JVM level and the platform you're on, and the exact changes you've made.  Be precise.
>
> You should probably try to solve the problem on a standalone Tomcat first, then apply the working config to JBoss, if possible.
>
>   - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat and Hex characters

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: arun kumar [mailto:arunbhat01@yahoo.com]
> Subject: Tomcat and Hex characters
> 
> What do i have to do to be able to pass hex values of 
> UTF-8 encoded strings that represent characters of 
> foreign languages (like say Chines/Japanese) to my 
> servlet so it is read correctly?

Start by studying this (it's non-trivial, and it's not clear how running inside JBoss affects it):
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding

If that doesn't help, come back to the list and tell us what exact Tomcat version you're using, along with the JVM level and the platform you're on, and the exact changes you've made.  Be precise.

You should probably try to solve the problem on a standalone Tomcat first, then apply the working config to JBoss, if possible.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.