Sun Java System Web Server 7.0 Developer's Guide to Java Web Applications

Servlet Internationalization Issues

This section describes how Sun Java System Web Server 7.0 determines the character encoding for the servlet request and the servlet response. For information about encodings, see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html.

Servlet Request

When processing the servlet request, the server uses the following order of precedence, first to last, to determine the character encoding for the request parameters:

  1. The ServletRequest.setCharacterEncoding() method.

  2. A hidden field in the form, if specified using the form-hint-field attribute of the parameter-encoding element in the sun-web.xml file. For more information about this element, see parameter-encoding Element.

  3. The character encoding specified in the default-charset attribute of the parameter-encoding element in the sun-web.xml file. For more information about this element, see parameter-encoding Element.

Servlet Response

When processing a servlet response, the server uses the following order of precedence, first to last, to determine the response character encoding:

  1. The ServletResponse.setContentType () method or the ServletResponse.setLocale () method.

  2. The default encoding, which is ISO-8859–1.

To specify the character encoding that should be set in the Content-type header of the response if the response locale is set using the ServletResponse.setLocale method, use the locale-charset-map under the locale-charset-info element in the sun-web.xml file. For more information about this element, see locale-charset-info Element