tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Tomcat 7.0.19 character encoding issue with JSP
Date Thu, 01 Sep 2011 13:58:24 GMT
On 01/09/2011 03:41, David Wall wrote:
> I'm trying to track down a character encoding issue that I've been
> having, but don't really understand. Hopefully one of you will know what
> the answer is.

I suspect you need:
<%@ page pageEncoding="UTF-8" %>
at the start of your JSP.

.java files are written using UTF-8 by default so if what you see there
is wrong then the original .jsp file was read with the wrong encoding.

Tomcat determines the encoding based on a number of factors. For the
details see line 326 onwards of
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java?view=annotate

The short version is if it is XML, it uses the encoding defined in the
XML doc, if it isn't XML it uses the value of pageEncoding. The
fall-back is ISO-8859-1.

> <%@ page contentType="text/html; charset=utf-8" session="true"
> isELIgnored="true" %>

You'll still need this to tell the browser to use UTF-8 to display the data.

> So I figured it was the default character encoding of the JVM causing me
> some grief. I checked and the default on my Windows PC is Cp1252. But
> when I change this with the JVM argument -Dfile.encoding=UTF8, I am no
> better off.

That is expected. file.encoding is not always read/write and should
never be relied upon to fix any encoding problems.

HTH,

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message