You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by T P <tp...@mail.niksula.cs.hut.fi> on 2005/09/20 22:28:30 UTC

Charset configurations for JSP pages

Hello,

How to configure the character sets on JSP pages/HTTP replies so that
browser connecting to tomcat displays pages correctly? Currently i'm using
Tomcat-5.0.28.

I am unable to find any decent documentation on this. I have
JSP pages with character set ISO-8859-1 on disk. I reinstalled Linux
operating system. Previous installation used ISO-8859-1 character set
according to locale, new uses UTF-8. Now when browsing the site,
scandinavian characters (&auml; and &ouml;) are shown as ? on mozilla.
As curiosity, dynamic text coming from database is shown correctly, static
text on JSP page is not.

There are bunch of parameters and finding the right combination does not
seem to be trivial. For example there seems to be the following
parameters, for which it is hard to find extensive documentation:

On jsp page <%page%>-directive:
contentType
pageEncoding

On web.xml (tomcat configuration)
javaEncoding

Java system properties
file.encoding


TIA!



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


Re: Charset configurations for JSP pages

Posted by Bill Barker <wb...@wilshire.com>.
"Mieke Banderas" <mi...@gamebox.net> wrote in message 
news:20051203014115.496@smtprelay1.telia.com...
> Mark Thomas said:
>>Mieke Banderas wrote:
>>> Mark Thomas said:
>>>>Read the spec.
>>> Where in the spec?
>>
>>"JSP.4 Internationalization Issues" would seem to be a blinding
>>obvious place to start.
>
> I didn't find anything obvious in that section. It says:
> "A JSP page uses a character encoding.  The encoding can be described
> explicitly using the pageEncoding attribute of the page directive.  The
> character  encoding defaults to the encoding indicated in the contentType
> attribute of the  page directive if it is given, or to ISO-8859-1 
> otherwise."
> Which is more or less what T P already had got down in the question.
>
> So it seems there were something else going on, unless I miss something.
> Is Tomcat 3, 4 and 5 very different in the settings that need to be done?
> I still use 3 and 4.
>

Tomcat 3 is very different from 4 & 5.  In particular, internationalization 
isn't very well supported in JSP 1.1/Servlet 2.2.  Tomcat 3.3.x has some 
specialized extensions to work around this, but at the end of the day it's 
an outdated spec problem.

> Some links list searchers may appreciate:
> The JSP 1.1, 1.2 (the one I needed myself) and 2.0 specifications are
> downloadable (after reg) from Sun here:
> <http://java.sun.com/products/jsp/reference/api/index.html>
> (Scroll down to the specs)
> and JSP documentation is here:
> <http://java.sun.com/products/jsp/docs.html>
>
> While not JSP specific, I've found this useful link page of Java
> Internationalization oriented writings as well:
> "i18ngurus.com, the open internationalization resources directory" -> /
> Programming/Java
> <http://www.i18ngurus.com/docs/984813264.html>
>
> and O'Reilly released the book "Java Internationalization" in 2001
> <http://www.javainternationalization.com/blog/> 




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


Re: Charset configurations for JSP pages

Posted by Mark Thomas <ma...@apache.org>.
Mieke Banderas wrote:
> Some links list searchers may appreciate:
> The JSP 1.1, 1.2 (the one I needed myself) and 2.0 specifications are
> downloadable (after reg) from Sun here: 
> <http://java.sun.com/products/jsp/reference/api/index.html>
> (Scroll down to the specs)
> and JSP documentation is here: 
> <http://java.sun.com/products/jsp/docs.html>

For 1.2, the errata are also relevant. See 
http://www.jcp.org/aboutJava/communityprocess/maintenance/jsr053/errata_1_2_a_20020321.html


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


Re: Charset configurations for JSP pages

Posted by Mieke Banderas <mi...@gamebox.net>.
Mark Thomas said:
>Mieke Banderas wrote:
>> Mark Thomas said:
>>>Read the spec.
>> Where in the spec?
>
>"JSP.4 Internationalization Issues" would seem to be a blinding 
>obvious place to start.

I didn't find anything obvious in that section. It says:
"A JSP page uses a character encoding.  The encoding can be described 
explicitly using the pageEncoding attribute of the page directive.  The
character  encoding defaults to the encoding indicated in the contentType
attribute of the  page directive if it is given, or to ISO-8859-1 otherwise."
Which is more or less what T P already had got down in the question.

So it seems there were something else going on, unless I miss something.
Is Tomcat 3, 4 and 5 very different in the settings that need to be done?
I still use 3 and 4.

Some links list searchers may appreciate:
The JSP 1.1, 1.2 (the one I needed myself) and 2.0 specifications are
downloadable (after reg) from Sun here: 
<http://java.sun.com/products/jsp/reference/api/index.html>
(Scroll down to the specs)
and JSP documentation is here: 
<http://java.sun.com/products/jsp/docs.html>

While not JSP specific, I've found this useful link page of Java
Internationalization oriented writings as well:
"i18ngurus.com, the open internationalization resources directory" -> /
Programming/Java
<http://www.i18ngurus.com/docs/984813264.html>

and O'Reilly released the book "Java Internationalization" in 2001
<http://www.javainternationalization.com/blog/>


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


Re: Charset configurations for JSP pages

Posted by Mark Thomas <ma...@apache.org>.
Mieke Banderas wrote:
> Mark Thomas said:
>>Read the spec.
> Where in the spec?

"JSP.4 Internationalization Issues" would seem to be a blinding 
obvious place to start.

Mark



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


Re: Charset configurations for JSP pages

Posted by Mieke Banderas <mi...@gamebox.net>.
Mark Thomas said:

>Read the spec.

Where in the spec?


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


Re: Charset configurations for JSP pages

Posted by Mark Thomas <ma...@apache.org>.
T P wrote:
> There are bunch of parameters and finding the right combination does not
> seem to be trivial. For example there seems to be the following
> parameters, for which it is hard to find extensive documentation:
> 
> On jsp page <%page%>-directive:
> contentType
> pageEncoding

Read the spec.

> On web.xml (tomcat configuration)
> javaEncoding

For 99.9% of use cases the default of UTF-8 will be fine.

> Java system properties
> file.encoding

This is a read-only property and for properly written pages has no effect.



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