• Post Reply Bookmark Topic Watch Topic
  • New Topic

unicode post request parameters  RSS feed

 
kourosh parsa
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I developed some servlet to get unicode parameters via post request.
It worked perfectly fine since I set the encoding as below:

Now that I have set up my dev environment on a new machine with new eclipse, it does not work.
It displays Ï instead of π.
I've already tried adding URIEncoding="UTF-8" to server.xml which did not help since it only affect get not post.
I figured out how to get the parameter with correct encoding on the new system:


but I cannot believe that this is the solution because then what's the point of having request.getParameter.
I already know that:

would not work.
If there is an expert who knows about this issue, please let me know what you think and whether there is a better solution than this.
Thanks
 
Paul Clapham
Sheriff
Posts: 22505
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm surprised your first try worked, because you're setting the request's encoding after the servlet container (whichever server that might be) has deciphered the request. Which of course is a task which uses the request's encoding.

It's possible to configure your server to use UTF-8 as default encoding for requests and responses; different servers use a wide variety of methods to provide that ability, so you'd have to dig through your server's documentation to find out how. Perhaps somebody had already done that for your first server but not for your second server.

Alternatively, what I once did was to write a Filter which set the request's and response's encoding to UTF-8, and to make it run before any other Filters and apply to all requests.
 
kourosh parsa
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. I myself was the one who set the tomcat 7 server and also on the production server, tomcat already was setup and it had been working just fine...
I do not exactly know what you mean by using a filter. Would you be able to elaborate with a pseudo code please?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!