In response to a request by a client to obtain a document of a particular language, or perhaps due to preference setting by a client, a servlet can set the language attributes of a response back to a client. This information is communicated via the Content-Language header along with other mechanisms described in the HTTP/1.1 specification. The language of a response can be set with the setLocale method of the ServletResponse interface. This method must correctly set the appropriate HTTP headers to accurately communicate the locale to the client. For maximum benefit, the setLocale method should be called by the developer before the getWriter method of the ServletResponse interface is called. This will ensure that the returned PrintWriter is configured appropriately for the target Locale . If the setContentType method is called after the setLocale method and there is a charset component to the given content type, the charset specified in the content type overrides the value set via the call to setLocale . |