Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with URLEncoder.encode and request.getparameter with chinese characters

 
Shah Jenish
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the URL that I use to invoke my servlet from my applet

Code:

http://192.168.0.67/MyServlet?p1=団

As you can see, the parameter has a unicode character 団. So I use

Code:

URLEncoder.encode ( "団", "UTF-8" ) ;

and now my URL becomes

Code:

http://192.168.0.67/MyServlet?p1=%E5%9B%A3

However, from the servlet, calling

Code:

request.getParameter ( "p1" ) ;

already return some gibberish that cannot be decoded with URLDecoder. BTW, invoking

Code:

URLDecoder.decode ( "%E5%9B%A3", "UTF-8" ) ;

does give me the original unicode character. It`s just that the servlet has garbled the parameter before it can even be decoded. Does anyone know why?

Request.gerparameter doesnt decode parameter with UTF-8?
 
veda bandaru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You need to translate the character set of the parameter

Ex:


Its just an example iso code, you need to find the correct one for Chinese.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic