tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allen,Eva" <all...@oclc.org>
Subject RE: How to get Tomcat to send proper charset?
Date Wed, 13 Jun 2007 22:53:46 GMT
Thanks, Andrew, but it just isn't working.  I went and got proximotron
and I'm looking at the headers.  What I've found is that when I don't
explicitly set the character set in the content type header and the
character set uses UTF-8, the only thing that's wrong is the browser
doesn't recognize the character set as UTF-8.  If I go in and manually
change the character set in the browser to UTF-8 everything displays as
it should.

However, if I use response.setContentType("text/html; charset=UTF-8");

then the header gets set right, but the content is pure gibberish.  I
don't know what is coming back.  It doesn't look right in either
iso-8859-1 or utf-8.  This worked fine in Tomcat 4; I didn't have to
specify what the character set was for the browser to "know" because it
was in the meta header for the web page.  For some reason, in Tomcat 5,
the meta header is being ignored and I can't seem to luck up on the
right combination to get the browser to display UTF-8 when the string
that coming back to be posted is UTF-8.  I know I can't be the first
person to need this!  What changed about Tomcat 5 that would break this?
Any clues as to what I can change in my code to fix it?  I spent a great
deal of last night looking for a solution and all I found was encoding
in the URI doesn't work like it used to; there was nothing about
encoding in the rendered web page itself.

-----Original Message-----
From: Andrew Chapman [mailto:andrew.chapman@clicktools.com] 
Sent: Wednesday, June 13, 2007 4:26 AM
To: users@tomcat.apache.org
Subject: RE: How to get Tomcat to send proper charset?

Eva,

This will work. I think the problem in the response.setContentType() is
as simple as a typo. An extra quote seems to have crept in, so:

response.setContentType("text/html; charset="UTF-8")

SHOULD BE

response.setContentType("text/html; charset=UTF-8")

Andy

-----Original Message-----
From: Allen,Eva [mailto:allene@oclc.org]
Sent: 13 June 2007 04:36
To: Tomcat Users List
Subject: How to get Tomcat to send proper charset?

We just recently switched our platform from tomcat 4.124 to Tomcat
5.5.23 and now languages Japanese, Chinese (traditional) and Chinese
(simplified) are not displaying properly.   Here's a little background.

We use servlets to build HTML code to be output (please no comments on
how bad an idea this is; it's legacy code, we must support it).  What
we'd done up until now is determine the language to be used from the
login page, save it in the session and use it to determine what
character set should be output.  The character set was explicitly stated
in a meta header on the output web page like so

<html lang=ja>
<head>
<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
or

<html lang=en>
<head>
<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

That is no longer working.  It was suggested that tomcat was paying
attention to the HTTP Content-Type header to determine what character
set to display so I modified the code a little bit to use

response.setContentType("text/html; charset="UTF-8") or
response.setContentType("text/html; charset="iso-8859-1")

depending on which was appropriate.

But even though that response header is explicitly set in the code,
somehow, somewhere it's changed again, because I've determined that the
content type response header looks like this:

 Content-Type: text/html;charset=ISO-8859-1

What's going on?  Why is Tomcat ignoring what we're telling it?  How can
we get Tomcat to send the correct response header so that our Japanese
and Chinese readers can see something other than gibberish?
--
Eva Allen
Consulting Software Engineer, OCLC, Inc.
6565 Kilgour Pl., Dublin, OH  43017
614.764.6009 | allene@oclc.org
Views contained herein are my own; they do not necessarily reflect those
of my employer



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