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.

Dieser Beitrag wurde unter Groovy and Grails, Java Runtimes - VM, Appserver & Cloud, Java Web Frameworks abgelegt und mit , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

3 Antworten zu 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.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Log Out / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Log Out / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Log Out / Ändern )

Verbinde mit %s