Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Corrected some misprints

...

References: Tomcat 6 HTTP Connector, Tomcat 6 AJP Connector

Anchor
Q3
Q3
How do I change how POST parameters are interpreted?

...

  1. Set URIEncoding="UTF-8" on your <Connector> in server.xml
  2. Use a character encoding filter with the default encoding set to UTF-8
  3. Change all your JSPs to set the correct Content-Type (use <%@page cotnentTypecontentType="mime/type; charset=UTF-8" %>)
  4. Change all your servlets to set the content type for responses to UTF-8
  5. Change any content-generation libraries you use (Velocity, Freemarker, etc.) to use UTF-8 as the content type
  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.

...

The character set for HTTP query strings (that's the technical term for 'GET parameters') can be found in sections 2 and 2.1 the "URI Syntax" specification. The character set is defined to be US-ASCII. Any character that does not map to US-ASCII must be encoded in some way. Section 2.1 of the URI Syntax specification says that characters outside of US-ASCII must be encoded using % escape sequences: each character is encoded as a literal % followed by the two hexadecimal codes which indicate its character code. Thus, a (US-ASCII character code 0x9797 = 0x61) is equivalent to %97 %61. There is no default encoding for URIs specified anywhere, which is why there is a lot of confusion when it comes to decoding these values.

...