Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internationalization: safe transfer of text from client to server

Status
Not open for further replies.

borbjo

Programmer
Mar 29, 2002
33
NO
I have a problem with internationalization.

My program consist of a Swing GUI client which recieves input from the user, a servlet running on Tomcat and a MySQL database.

When I send text from the client I encode it using URLEncoder.encode("text", "UTF-8").

The problem is that when it is recieved in the servlet, it no longer looks URLEncoded (the %´s have been stripped etc.) - so decoding it doesn´t work.

Anyone experienced similar problems?
 
I think if you encode using UTF, you sould use function similat to readUTF to read it correctly.

Ion Filipski
1c.bmp
 
Ok, I use HttpServletRequest's getParameter() method.

Maybe that's where the problem is.
 
Java may be incorrectly converting the text for you.

If the server is on unix set the environment variable LANG=en_US before starting the server.

If the server is on Windows I guess you could try running your server like:

java -Dfile.encoding=ISO8859-1 -Duser.region=US MyServerMainClass

Sean McEligot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top