Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 64505 invoked from network); 24 Apr 2007 18:40:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Apr 2007 18:40:36 -0000 Received: (qmail 74217 invoked by uid 500); 24 Apr 2007 18:40:24 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 74200 invoked by uid 500); 24 Apr 2007 18:40:24 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 74189 invoked by uid 99); 24 Apr 2007 18:40:24 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2007 11:40:23 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of rashmi.sub@gmail.com designates 66.249.82.239 as permitted sender) Received: from [66.249.82.239] (HELO wx-out-0506.google.com) (66.249.82.239) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2007 11:40:16 -0700 Received: by wx-out-0506.google.com with SMTP id i26so2729018wxd for ; Tue, 24 Apr 2007 11:39:55 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uRyyZYB37GVyFmMswGjCXWRDInFzsTOzuZA5y5EGL8NZY0Xa5aHjuDQaRUR+t9CWY4QM/7szGehR6isGNCEJP6j0zPmhLgDMMbh4FQjRmiF39uj1ueSNpl+MGEL2LWkSNUmb0wU2GJzNpLsaiPHR8joN7lW4iqMb/gJux37E1/0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=nCea2gbWFwlrdQQz73c7AGAiwBJ4upy9MuZhXnhlt+fczmWutC/0bcbmUWd/NI0Stxcnx2dmmuKBCnAr1AZxUivAFJXfMapdSxm9wbpRXY+xsPn+sFDlDEbM3wgQ/FKjf9BBiUd0JdTyIiX/otYGqRYkVp87Oh3WaOl+xf6YPMc= Received: by 10.90.25.3 with SMTP id 3mr2526759agy.1177439995100; Tue, 24 Apr 2007 11:39:55 -0700 (PDT) Received: by 10.90.36.8 with HTTP; Tue, 24 Apr 2007 11:39:55 -0700 (PDT) Message-ID: <3ef28230704241139y7b016c71k64dc737c0c6d461c@mail.gmail.com> Date: Tue, 24 Apr 2007 14:39:55 -0400 From: "Rashmi Rubdi" To: "Tomcat Users List" Subject: Re: charset encoding bug In-Reply-To: <719601.96550.qm@web53401.mail.re2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <719601.96550.qm@web53401.mail.re2.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Sean, Thank you for defining the problem. I tried a few variations of code in Servlets and JSPs and was able to get only "application/xml" instead of "application/xml;some character encoding" . The only time I got "application/xml;some character encoding" was when there was a conflicting setting in the JSP page. For example in the following case the character set was appended, because if you notice in the page directive, there's a conflict: <%@ page contentType="text/html;charset=UTF-8" language="java" %> with the explicit response set in the body. ~~~~~~~~~~~~~~~~~~~~~~~~~~ FirstTest.jsp ~~~~~~~~~~~~~~~~~~~~~~~~~~ <%@ page contentType="text/html;charset=UTF-8" language="java" %> Set Content type: <% response.setContentType("application/xml"); %>

Get Content type: <%=response.getContentType()%> The output was: - - </head> - <body> Set Content type: <br /> <br /> Get Content type: application/xml;charset=UTF-8 </body> </html> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SecondTest.jsp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If I removed all all conflicting content-types and made them uniform as follows: <%@ page contentType="application/xml" language="java" %> <html> <head><title> Set Content type: <% response.setContentType("application/xml"); response.setLocale(null); %>

Get Content type: <%=response.getContentType()%> gives the following output: - - </head> - <body> Set Content type: <br /> <br /> Get Content type: application/xml </body> </html> However, removing the character set, resulted in an error on Tomcat's console: java.lang.NullPointerException at org.apache.catalina.util.CharsetMapper.getCharset(CharsetMapper.java:106) Researching a little bit on the HTTP Content-Type header lead me to http://www.ietf.org/rfc/rfc3023.txt on page 6 it states: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3.1 Text/xml Registration MIME media type name: text MIME subtype name: xml Mandatory parameters: none Optional parameters: charset Although listed as an optional parameter, the use of the charset parameter is STRONGLY RECOMMENDED, since this information can be used by XML processors to determine authoritatively the character encoding of the XML MIME entity. The charset parameter can also be used to provide protocol-specific operations, such as charset- based content negotiation in HTTP. "utf-8" [RFC2279] is the recommended value, representing the UTF-8 charset. UTF-8 is supported by all conforming processors of [XML]. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The above might explain why Tomcat expects the character set parameter to be appended. -Regards Rashmi --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org