Examples: autoRequestEncoding and autoResponseEncoding encoding examples

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.3 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 includes the setCharacterEncoding(String encoding) method. Also, If the value is set to false for a response, the Web container cannot set a response content type.

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


 

See Also


autoRequestEncoding and autoResponseEncoding
Internationalization

 

See Also


Web applications: Resources for learning