IBM


13.7.7 Automatic HTTP request and response encoding

The Web container no longer automatically sets request and response encodings and response content types. The programmer is expected to set these values using the methods available in the Servlet 2.4 API. If you want the appserver to attempt to set these values automatically, check the Automatic Request Encoding enabled option in order to have the request encoding value set. Similarly, you can check the Automatic Response Encoding enabled option in order to have the response encoding and content type set.

The default value of the autoRequestEncoding and autoResponseEncoding extensions is false, which means that both the request and response character encoding is set to the Servlet 2.4 specification default of ISO-8859-1. Different character encodings are possible if the client defines character encoding in the request header, or if the code uses 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.

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 server's 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 you set the autoResponseEncoding value to true and the client:

- The client did not specify character encoding in the request header.

- 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.


Redbooks ibm.com/redbooks

Next