public void setLocale(Locale locale)
    {
        if (locale == null || isCommitted())
            return; 

        _locale = locale;
        setHeader(HttpFields.__ContentLanguage,locale.toString().replace('_','-'));
                         
        if (this._outputState==0)
        {
            /* get current MIME type from Content-Type header */                  
            String type=_httpResponse.getField(HttpFields.__ContentType);
            if (type==null)
            {
                // servlet did not set Content-Type yet
                // so lets assume default one
                type="application/octet-stream";
            }
            
            HttpContext httpContext=_servletHttpRequest.getServletHandler().getHttpContext();
            if (httpContext instanceof ServletHttpContext)
            {
                String charset = ((ServletHttpContext)httpContext).getLocaleEncoding(locale);
                if (charset != null && charset.length()>0)
                {
                    int semi=type.indexOf(';');
                    if (semi<0)
                        type += "; charset="+charset;
                    else if (!_charEncodingSetInContentType)
                        type = type.substring(0,semi)+"; charset="+charset;
                    
                    setHeader(HttpFields.__ContentType,type);
                }
                
            }
        }
    }
public void setLocale ( Locale locale ) { if ( locale == null || isCommitted ( ) ) return ; _locale = locale ; setHeader ( HttpFields . __ContentLanguage , locale . toString ( ) . replace ( '_' , '-' ) ) ; if ( this . _outputState == 0 ) { String type = _httpResponse . getField ( HttpFields . __ContentType ) ; if ( type == null ) { type = "application/octet-stream" ; } HttpContext httpContext = _servletHttpRequest . getServletHandler ( ) . getHttpContext ( ) ; if ( httpContext instanceof ServletHttpContext ) { String charset = ( ( ServletHttpContext ) httpContext ) . getLocaleEncoding ( locale ) ; if ( charset != null && charset . length ( ) > 0 ) { int semi = type . indexOf ( ';' ) ; if ( semi < 0 ) type += "; charset=" + charset ; else if ( ! _charEncodingSetInContentType ) type = type . substring ( 0 , semi ) + "; charset=" + charset ; setHeader ( HttpFields . __ContentType , type ) ; } } } }
Sets the locale of the response, setting the headers (including the
Content-Type's charset) as appropriate.  This method should be called
before a call to {@link #getWriter}.  By default, the response locale
is the default locale for the server.

@see   #getLocale
@param locale the Locale of the response