In a tomcat deployed server, The non-english characters getting from web services are not displaying correctly.
We write a main program in java and retrieved the data through web-service. its parsed well and correctly displayed the non-english character.
So the issue is with tomcat, after investigation we found this.
In the catalina.bat (catalina.sh) add the java args... set JAVA_OPTS=-Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8 then all encodings seem to come across as UTF-8 by default..
This resolved the problem.
source: http://marc.info/?l=tomcat-user&m=108576957301771&w=3
----------------------
+20110113
Added some more info:
Configuring Tomcat's URI encoding
By default, Tomcat uses ISO-8859-1 character encoding when decoding URLs received from a browser. This can cause problems when Confluence's encoding is UTF-8, and you are using international characters in attachment or page names.
- Edit conf/server.xml and find the line where the Coyote HTTP Connector is defined. It will look something like this, possibly with more parameters:
<
Connector
port
=
"8080"
/>
- Add a URIEncoding="UTF-8" property to the connector:
<
Connector
port
=
"8080"
URIEncoding
=
"UTF-8"
/>
- Restart Tomcat
Also check this
Hi David, thanks for this post ! I love it ! It finally solved my issues !
ReplyDeleteI had 2 different Linux machines, with THE SAME catalina.sh configuration and with THE SAME application running (the same war file) and even this on 1 server the encoding was OK, and on the other it was NOT OK !! I guess Tomcat takes the setting somehow from the system. But the redefining it by the Java settings you proposed WORKS !
Thanks a lot again.
-josef-
Its Pleasure to hear .. Thank God.
ReplyDeleteLove Love Love!!!
ReplyDeleteit helped me ... thank you :)
ReplyDeleteThanks a lot
ReplyDeleteI run as a service on windows and put it into --JvmOptions in service.bat file
--JvmOptions "-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;-Djavax.servlet.request.encoding=UTF-8;-Dfile.encoding=UTF-8" ^
.....>Edit conf/server.xml and find the line where the Coyote HTTP Connector is defined. It will look something like this, possibly with more parameters:
ReplyDeleteAdd a URIEncoding="UTF-8" property to the connector:
Restart Tomcat.....<
this saved my day.
thank you very much.
The second one worked for me ie editing conf/server.xml
ReplyDeleteThanks a million
ReplyDeleteBut note, that URIEncoding="UTF-8" only applies to GET request. For POST request you may need CharacterEncoding filter - http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q3
ReplyDelete