Tomcat : Modify default URL encoding

This page last changed on Feb 23, 2009 by Kees de Kooter

URL Encoding Blues

I have been struggling with (url) encoding issues for quite some time. The customer needed to have literal strings in REST-style urls. The default encoding on his platform (Windoze) worked well until they wanted to add words in east european languages, like s-es with funny hats.

On my linux box everything worked well after setting the encoding to UTF-8 in the most obvious places. On the customer's target platform however things were messed up.

After ruling out both IIS and the ISAPI redirector I finally solved it by adding a Filter with the following line:


The REST-style URLs are now interpreted properly.

However the app also contains old fashioned urls. One problem remained: encoded strings in request parameters (i.e. after the "?"). The funny thing is that POST requests work fine, GETs mess up.

This time tomcat is to blame. Atlassian to the rescue.

Apparently tomcat defaults to ISO-8859-1. I added the following to the HTTP and AJP connectors and now it is working fine.