Mamad Purbo

Tomcat 5.5 Encoding Problem

It is mysterious as to why Tomcat 5.5.x developers decided to make request's character encoding conversion not enabled by default. Traditionally (as with Tomcat 5.0.x and below), when the browser doesn't specify the page's character encoding (as browsers never do), then Tomcat would simply assume that ISO-8859-1 is used. Which means the data sent by the browser is garbled (or for Japanese characters it's usually called mojibake/文字化け) by default.

To fix the problem, it is a common practice that we simply need to add a character encoding filter, so that we can specify the encoding for all incoming request. But with Tomcat 5.5.x something weird is happening. Even if we do following setting on a filter:

request.setCharacterEncoding(encoding);


The above code doesn't have any effect whatsoever on Tomcat 5.5.x, unless we add the following setting to server.xml configuration file:

<Connector port="8080" .... useBodyEncodingForURI="true"/>


For people working on environment other than English, it is a royal pain in the ass to always remember having to add those crap on the configuration file.