autoRequestEncoding and autoResponseEncoding

Starting with WebSphere® Application Server Version 5, the web container no longer automatically sets request and response encodings, and response content types. Programmers are expected to set these values using available methods in the Servlet 2.3 specification or later. If programmers choose not to use the character encoding methods, they can specify the autoRequestEncoding and autoResponseEncoding extensions, which enable the application server to set the encoding values and content type.

The values of the autoRequestEncoding and autoResponseEncoding extensions are either true or false. The default value for both extensions is false. If the value is false for both autoRequestEncoding and autoResponseEncoding, then the request and response character encoding is set to the Servlet Specification default, which is ISO-8859-1. Also, if the value is set to false for a response, the web container cannot set a response content type. Different character encodings are possible if the client defines character encoding in the request header, or if the code includes the setCharacterEncoding(String encoding) method.

If the autoRequestEncoding value is set to true, and the client did not specify character encoding in the request header, and the code does not include the setCharacterEncoding(String encoding) method, the web container tries to determine the correct character encoding for the request parameters and data.

Use an assembly tool to change the default values for the autoRequestEncoding and autoResponseEncoding extensions.

The web container performs each step in the following list until a match is found:

  • Looks at the character set (charset) in the Content-Type header.
  • Attempts to map the servers locale to a character set using defined properties.
  • Attempts to use the DEFAULT_CLIENT_ENCODING system property, if one is set.
  • Uses the ISO-8859-1 character encoding as the default.

If the autoResponseEncoding value is set to true, and the client did not specify character encoding in the request header, and the code does not include the setCharacterEncoding(String encoding) method, the web container does the following:

  • Attempts to determine the response content type and character encoding from information in the request header.
  • Uses the ISO-8859-1 character encoding as the default.