tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Tomcat Wiki] Update of "FAQ/CharacterEncoding" by markt
Date Tue, 04 Dec 2007 18:02:29 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for change notification.

The following page has been changed by markt:

The comment on the change is:
Bring all the encoding stuff together into a single page.

New page:
= Character Encoding Issues =

== Questions ==

'''What is the default character encoding?'''

If a character encoding is not specified, the Servlet specification requires that an encoding
of ISO 8859-1 is used.

'''How do I change how GET parameters are interpreted?'''

Set the URIEncoding parameter on the Connector element in server.xml.

'''How do I change how POST parameters are interpreted?'''

POST requests should specify the encoding of the parameters and values they send. Since many
clients fail to set an explicit encoding, the default is used (ISO 8859-1). In many cases
this is not the preferred interpretation so one can employ a javax.servlet.Filter to set request
encodings. Writing such a filter is trivial. Furthermore Tomcat already comes with such an
example filter. Please take a look at:

'''How can I test if my configuration will work correctly?'''

The following sample JSP should work for any input. If you set the URIEncoding="UTF-8" on
the connector, it will also work with method="GET".
<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     <title>Character encoding test page</title>
     <p>Data posted to this form was:

     <form method="POST" action="index.jsp">
       <input type="text" name="mydata">
       <input type="submit" value="Submit" />
       <input type="reset" value="Reset" />

'''I'm having a problem with character encoding in tomcat 5'''

In Tomcat 5 - there have been issues reported with respect to character encoding (usually
of the the form "request.setCharacterEncoding(String) doesn't work"). Odds are, its not a
bug. Before filing a bug report, see these bug reports as well as any bug reports linked to
these bug reports:

 * [ 23929]
 * [ 25360]
 * [ 25231]
 * [ 25235]
 * [ 22666]
 * [ 24557]
 * [ 24345]
 * [ 25848]

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message