tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: pageEncoding and Jasper
Date Fri, 08 Feb 2002 04:02:00 GMT


On Fri, 8 Feb 2002 yoko@netpotlet.com wrote:

> Date: Fri, 08 Feb 2002 12:26:51 +0900 (JST)
> From: yoko@netpotlet.com
> Reply-To: Tomcat Developers List <tomcat-dev@jakarta.apache.org>
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: pageEncoding and Jasper
>
> From: "Craig R. McClanahan" <craigmcc@apache.org>
> Subject: RE: pageEncoding and Jasper
> Date: Thu, 31 Jan 2002 06:49:39 -0800 (PST)
> Message-ID: <20020131064817.E77425-100000@icarus.apache.org>
>
> > On Thu, 31 Jan 2002, Kevin Jones wrote:
> >
> > > Date: Thu, 31 Jan 2002 10:37:10 -0000
> > > From: Kevin Jones <kevinj@develop.com>
> > > Reply-To: Tomcat Developers List <tomcat-dev@jakarta.apache.org>
> > > To: 'Tomcat Developers List' <tomcat-dev@jakarta.apache.org>
> > > Subject: RE: pageEncoding and Jasper
> > >
> > > So it's only used when compiling the JSP to a servlet?
> >
> > If "it" is the pageEncoding attribute of the <%@ page %> directive, then
> > the answer is yes.
>
> Craig, the answer is "no".

Well, that's not the answer given by the JSP Specification ;-).

In the JSP 1.2 spec, see section 2.10.1, Table JSP.2-1, bottom of page 52,
where the "pageEncoding" attribute is defined:

  Defines the character encoding of the JSP page.

There is further text in Chapter 3 making it clear that this affects the
compiler only.  It has zero impact on what is sent to a browser as part of
an HTTP response.

> The pageEncoding attribute is used to "read" only.

Technically this is true, but remember that the source of the JSP page is
read only once, by the JSP compiler, so the answer to "it's only used when
compiling the JSP to a servlet" is correct.

> Servlet codes
> generated from JSP pages are written in UTF-8. You can confirm
> the encoding of generated Servlet codes by a browser (Netscape:
> View -> Character Coding) or a utf-8 enabled editor.
> So, the encoding for compile is UTF-8 only.
>

If you want to tell the container what character encoding to send on a
response, use the "contentType" attribute of the <%@ page %> directive:

  <%@ page contentType="text/html;charset=UTF-8" %>

I had to do this in my Struts demo at JavaOne Japan, for example, in
order to display the Japanese characters correctly.  Setting pageEncoding
would not have done this.

> ---
> Yoko Kamei Harada, Web Studio Ne-Po-Le
> http://www.netpotlet.com/
>

Craig


--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message