Apache Tomcat & UTF-8

Apache Tomcat out-of-the-box uses ISO-8859-1 (also called Latin 1). How to use UTF-8 in Apache Tomcat?

Apache Tomcat out-of-the-box uses ISO-8859-1 (also called Latin 1). This encoding doesn't contain lots of characters, which are commonly used outside USA. UTF-8 encoding is de facto standard, which contains characters missing in ISO-8859-1. How to use UTF-8 in Apache Tomcat?

 

First go to [apache-tomcat]/conf/server.xml and add to all Connectors this attribute: URIEncoding="UTF-8". This will enable UTF-8 for HTTP GET parameters.

 

Next open [apache-tomcat]/conf/web.xml and uncomment setCharacterEncodingFilter. Do not forget to uncomment not only filter definition, but also filter-mapping. This will enable UTF-8 for HTTP POST parameter. Btw you could set this filter inside your web application.

 

Now if you use UTF-8 everywhere in your application, you won't have any trouble. For more information follow this link: http://wiki.apache.org/tomcat/FAQ/CharacterEncoding