Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Made small adustments and clarification about request content encoding settings.

...

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 is US-ASCII for application/x-www-form-urlencoded and ISO-8859-1 for all other content types.

...

It is also possible to define such a filter in the Tomcat installation configuration file conf/web.xml, which would set the request character encoding across all web applications without the need for any web.xml modifications. In fact the latest Tomcat versions come with sections in conf/web.xml that already configure a filter to set the request character encoding to UTF-8. Simply edit conf/web.xml and uncomment both the definition and the mapping of the filter named setCharacterEncodingFilter.

...

  1. Set URIEncoding="UTF-8" on your <Connector> in server.xml. References: HTTP Connector, AJP Connector.
  2. Use Set the default request character encoding either in the Tomcat conf/web.xml file or in the web app web.xml file; either by setting <request-character-encoding> or by using a character encoding filter with the default encoding set to UTF-8.
  3. Change all your JSPs to include charset name in their contentType. For example, use <%@page contentType="text/html; charset=UTF-8" %> for the usual JSP pages and <jsp:directive.page contentType="text/html; charset=UTF-8" /> for the pages in XML syntax (aka JSP Documents).
  4. Change all your servlets to set the content type for responses and to include charset name in the content type to be UTF-8. Use response.setContentType("text/html; charset=UTF-8") or response.setCharacterEncoding("UTF-8").
  5. Change any content-generation libraries you use (Velocity, Freemarker, etc.) to use UTF-8 and to specify UTF-8 in the content type of the responses that they generate.
  6. Disable any valves or filters that may read request parameters before your character encoding filter or jsp page has a chance to set the encoding to UTF-8. For more information see http://www.mail-archive.com/users@tomcat.apache.org/msg21117.html.

...