DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12559>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12559

setLocale gives wrong content type

           Summary: setLocale gives wrong content type
           Product: Tomcat 5
           Version: Unknown
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The following entry in web.xml set a locale mapping to encoding.

      <locale-encoding-mapping-list>
        <locale-encoding-mapping>
            <locale>zh</locale>
            <encoding>gb2312</encoding>
        </locale-encoding-mapping>
      </locale-encoding-mapping-list>

The servlet (AdminServlet) set the locale of response if the request parameter 
has "lan".

When access /admin?lan=zh, the broswer tried to save the file as a binary file.
When access /admin?lan=en, the broswer tried to save the file as a binary file.
When access /admin, the broswer shown the HTML file
When access /admin?lan=(other), the broswer shown the HTML file.

It seemed the setLocale() incorrectly changed the content_type of the response 
when the locale to be set to zh or en.

public class AdminServlet extends HttpServlet {

    String precedence="starting";
    
    public void init(ServletConfig sc) throws ServletException {

    }


    public void service (ServletRequest request,ServletResponse response) 
throws ServletException, IOException {
        
       response.setContentType("text/html"); 
       
       String languagepref = request.getParameter("lan");
                if (languagepref!=null)
                {
                    response.setLocale(new java.util.Locale
(languagepref));                    
                }

        //response.setContentType("text/html"); 
        PrintWriter out = response.getWriter(); 
        
        out.println("<HTML>\n");
        out.println("<Body>\n");
        out.println("<p>Admin Servelt</p>\n");

        out.println("characterecoding: " + response.getCharacterEncoding()
+ "\n");
        out.println("locale: " + response.getLocale()+ "\n");
       // out.flush();
    }
}

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to