Solving Tomcat Encoding Problems in UTF-8 Webapps

The default configuration of Apache Tomcat 6 can cause encoding problems with URLs (links) that contain umlauts.

In a Grails project we had the case that html links didn’t work. The problem was that the URL contained parameters with umlauts.

The url wasn’t encoded as UTF-8, so the browser (Mozilla Firefox 3.5) couldn’t handle the url correctly.

To fix the problem in Tomcat 6, you have to edit the file server.xml.
Change the connector entry and add a URIEncoding attribute.

Replace the following line

<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/>

with this line

<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>

You can find an explanation of the URIEncoding attribute in the Tomcat documentation:

URIEncoding: This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used.

Short URL for this post: http://wp.me/p4nxik-le
This entry was posted in Groovy and Grails, Java Runtimes - VM, Appserver & Cloud, Java Web Frameworks and tagged , , , . Bookmark the permalink.

5 Responses to Solving Tomcat Encoding Problems in UTF-8 Webapps

  1. Pingback: Blog bookmarks 01/02/2011 « My Diigo bookmarks

  2. Pingback: Arragonán » Blog Archive » Configuración Tomcat para trabajar con UTF8

  3. Pingback: Tomcat, jQuery, Ajax und Character Encoding « Winkler, RWE, Kombjuda.

  4. this is not working pls repost correct one

  5. i don’t see any changes on my url

    when ..
    ————————————————————————————————————-
    my Url ::: application/ap.run%3bjsessionId=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    result :::: HTTP/1.1 404 Not Found
    ————————————————————————————————
    *****after change of

    —————————————————————————————–
    my Url ::: application/ap.run%3bjsessionId=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    same result like HTTP/1.1 404 Not Found(hear url should be
    ———————————————————————————————application/ap.run;jsessionId=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX ??????? then only it will succes response code 200)

Leave a Reply