Monday, April 29, 2013

Java encoding problem (in Tomcat and other servers)


The problem with encoding of served files appears when there's something wrong with java configuration on system level. Even providing proper headers inside HTTP responses can't help because all files are read improperly.


If you have problems with tomcat or other server and your files are served with broken encoding, you should edit your start script and add to JAVA_OPTS

 -Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8

I assume that you use utf8. If not, correct statement above with your encoding but please consider moving to utf8. 


No comments:

Post a Comment