I'm having problems with the character encoding of my webapp and would like to know how I can go about changing the default encoding of tomcat on the Linux production server to match the cp 1252 encoding of the dev server on windows (or at least experiment with different encoding until I can find the right one).


2 Answers 2


Add this to your catalina.sh script:

set JAVA_OPTS=-Djavax.servlet.request.encoding=Cp1252 -Dfile.encoding=Cp1252

Also in conf/server.xml you want to make this change so the URI encoding is set accordingly:

<Connector port="8080" URIEncoding="Cp1252"/>

If you use servlet filters you could add a call to response.setCharacterEncoding("Cp1252"); to all responses. If the response contains characters then your chosen encoding will be used.


Please see https://tomcat.apache.org/tomcat-8.5-doc/servletapi/javax/servlet/ServletResponse.html#setCharacterEncoding(java.lang.String)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.