0

I was getting unicode issue while encoding special characters. In my html, I am passing Special characters like 'Ã' , 'Ü' to post method to call java action class. Now, in tomcat logs I am getting garbled values like 'Ã<9c>' , Ã�

Thanks to @BalusC your post - How to pass Unicode characters as JSP/Servlet request.getParameter? solved my problem. Now, I am able to get correct values.

Solution - Depending upon the request type, UTF-8 encoding can be configured as following :

• For Get requests, we need to configure at the servlet container level by adding ‘URIEncoding’ attribute in element in tomcat/conf/server.xml

• For POST requests, create a filter which is mapped on the desired URL pattern for POST requests & set Character encoding as ‘UTF-8‘.

Thanks

Community
  • 1
  • 1
Jatin Gupta
  • 25
  • 2
  • 7

1 Answers1

0

Your charset is set to 8859-1 (charset=ISO-8859-1) and you use UTF-8 charactes, so I assume you have wrongly configured locale on the server or in the application.

Without seeing the code it is hard to guess, but I would check the output of locale command.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
  • the characters are already incorrect in the generated file, what we have in meta is indeed incorrect but is not the root cause here – Nicolas Filotto Jun 15 '16 at 18:51
  • Thanks @BalusC Your post http://stackoverflow.com/questions/10517268/why-do-unicode-characters-get-broken-in-a-jsp-servlet-request-getparameter solved my problem. Depending upon the request type, UTF-8 encoding can be configured as following : • For Get requests, we need to configure at the servlet container level by adding ‘URIEncoding’ attribute in element in tomcat/conf/server.xml • For POST requests, create a filter which is mapped on the desired URL pattern for POST requests & set Character encoding as ‘UTF-8‘. Thanks – Jatin Gupta Jun 16 '16 at 08:38