tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rashmi Rubdi" <>
Subject Re: charset encoding bug
Date Tue, 24 Apr 2007 20:19:59 GMT
Hi Sean,

You are right with the fact that the character set encoding does get
appended to the Content-Type header when the Locale is set.

However, according to the API docs:

"........ It also sets the response's character encoding appropriately
for the locale, if the character encoding has not been explicitly set
using setContentType(java.lang.String) or
setCharacterEncoding(java.lang.String), getWriter hasn't been called
yet, and the response hasn't been committed yet. If the deployment
descriptor contains a locale-encoding-mapping-list element, and that
element provides a mapping for the given locale, that mapping is used.
Otherwise, the mapping from locale to character encoding is container

So the above is expected behavior and not considered a bug, because
Tomcat 5.5.23 complies with Servlet 2.4 specification which is defined
in the JavaEE5 API.

Here's the code I just tried:

package test81;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import java.util.Locale;

public class ContentTypeServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException {
        processRequest(request, response);

    public void doPost(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException {
        processRequest(request, response);


    private void processRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {

        RequestDispatcher rd =



<%@ page contentType="application/xml" language="java" %>
  Get Content type:



  Get Content type:



To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message