tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: Response encoding problem
Date Sat, 18 Nov 2006 22:44:49 GMT
If your JSP page is being included from another servlet, then it won't be 
allowed to set the content-type (or charset) of the response.  Just a wild 
guess here :).

The HTTP/1.1 RFC states that the character encoding of the headers is 
iso-8859-1.  That is why Tomcat doesn't provide an option to change it.

"ruphus13" <ruphus13@gmail.com> wrote in message 
news:d28d676c0611181352x13f22e0au455406dbd6284a1e@mail.gmail.com...
> Hi - I'm trying to show utf-8 data in the browser from my jsp page.
> When the page renders, its character encoding is iso-8859-1, according
> to the browser.  The http
> response headers have the same encoding (iso-8859-1).
>
> Here's what's been done thus far:
>
> 1) meta tag set as follows:
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
>
> 2) jsp page encoding directive issued at the start of the jsp page.
> <%@page contentType="text/html; charset=UTF-8"%>
>
> 3) Generated jsp page has the following java code, as a consequence:
> try {
>     _jspxFactory = JspFactory.getDefaultFactory();
>     response.setContentType("text/html; charset=UTF-8");
>     pageContext = _jspxFactory.getPageContext(this, request, response,
>               null, false, 8192, true);
>     application = pageContext.getServletContext();
>     config = pageContext.getServletConfig();
>     out = pageContext.getOut();
>     _jspx_out = out;
> ...
> 4) When I save the page as an html file and open it as an html file in
> the browser, it renders correctly (due to the meta tag and no http
> headers), which is expected.
>
> 5) Manually changing the page encoding in firefox results in the page
> being rendered correctly.
>
> 6) Also set utf-8 in the connector settings in tomcat/conf/server.xml
> (for GETs?)
>
> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
>              port="8080" minProcessors="5" maxProcessors="75"
>              URIEncoding="UTF-8" useBodyEncodingForURI="true"
>              enableLookups="true" redirectPort="8443"
>              acceptCount="100" debug="0" connectionTimeout="20000"
>              useURIValidationHack="false" disableUploadTimeout="true" />
>
> 7) Set utf-8 in web.xml as follows:
> <servlet>
>       <servlet-name>jsp</servlet-name>
>       <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
>       <init-param>
>           <param-name>javaEncoding</param-name>
>           <param-value>UTF8</param-value>
>       </init-param>
> ...
>
> However, the page still shows up as iso-8859-1 (in firefox and IE),
> and viewing the response headers using a 3rd party plugin shows the
> content-type as ISO-8859-1
>
> Tomcat: 4.1.31
> JDK: 1.4.2
>
> What I'm hoping to learn is how to set the http response headers
> correctly.  It seems that the generated java code is doing the right
> thing.  However, the response header is still jacked...
>
> Any help will be very, very much appreciated!  I've gone through
> several articles on Goog as well as the tomcat mailing list... The
> brick wall is getting bloodier, and I'm getting woozy from the
> pounding...
>
> ---------------------------------------------------------------------
> 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
>
> 




---------------------------------------------------------------------
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


Mime
View raw message