You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ivan Montoro <iv...@yahoo.es> on 2004/04/04 21:14:13 UTC

JSP include directive and UTF-8 files in Tomcat 5

Hi everybody,

I've found that with the default installation of
Jakarta Tomcat 5.0.19, JSP include directive fails to
add UTF-8 files to the generated .java source file. If
you create a simple .jsp file with a <%@include
directive, and include an HTML file saved as UTF-8,
the resulting .java file contains the UTF-8
representation of the ISO-8859-1 characters.

I'm using the Unix "file" tool to see if the files
I have are UTF-8 or not, so that's clear. I've
tried the -Dfile.encoding=UTF-8 at setenv.sh and
javaEncoding property in web.xml with no result.

-------------------------------------------------
sample.jsp (UTF-8)
-------------------------------------------------
<%@ page contentType="text/html;charset=UTF-8" %>
<HTML><HEAD></HEAD><BODY>
hellô wórld!
<%@ include file="sample.html" %>
</BODY></HTML>
-------------------------------------------------
sample.html (UTF-8)
-------------------------------------------------
fóò bär
-------------------------------------------------
resulting file (sample_jsp.java at work/ folder)
-------------------------------------------------
[...]
      out.write("<HTML><HEAD></HEAD><BODY>\n");
      out.write("hellô wórld!\n");
      out.write("fóò bär\n");
      out.write("</BODY></HTML>\n");
[...]
-------------------------------------------------
output in the browser
-------------------------------------------------
hellô wórld! fóò bär
-------------------------------------------------
using "iconv -t ISO-8859-1" to convert .java file
-------------------------------------------------
      out.write("<HTML><HEAD></HEAD><BODY>\n");
      out.write("hell wrld!\n");
      out.write("fóò bär\n");
      out.write("</BODY></HTML>\n");
-------------------------------------------------

So, I believe that when you make a <%@include in
Tomcat 5, the file is opened and read in ISO-8859-1
encoding and then added to the .java source and
compiled. I'm right? Is there any way to tell Tomcat
to load files from <%@include in UTF-8?

Thanks!

Ivan

___________________________________________________
Yahoo! Messenger - Nueva versión GRATIS
Super Webcam, voz, caritas animadas, y más...
http://messenger.yahoo.es

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


RE: JSP include directive and UTF-8 files in Tomcat 5

Posted by Ivan Montoro <iv...@yahoo.es>.
Kewl! So I must add <%@ page pageEncoding="UTF-8"%> to
all the "included/common" JSP files! I cannot imagine
how can I be so lazy!!! Thanks :)

 --- Yansheng Lin <ya...@silvacom.com>
escribió: > 
> >And, of
> >course, there can be only one <%@ page directive,
> at
> >the "root" JSP page.
> 
> um, might not understand you correctly.  you can
> have as many as you want
> actually.
> i.e., <%@ page pageEncoding="utf-8" %>
> 	<%@ page contentType="text/html;charset=utf-8" %>
> 	<%@ page import="myOwnClass" %>
> 	...
> 
> Hope this helps:).
> 
> -Yan
> 
> -----Original Message-----
> From: Ivan Montoro
> [mailto:ivan_montoro_ten@yahoo.es] 
> Sent: Monday, April 05, 2004 11:33 AM
> To: Tomcat Users List
> Subject: RE: JSP include directive and UTF-8 files
> in Tomcat 5
> 
> 
> The fact is that all JSP pages are created in the
> work/ directory in UTF-8, at least with Tomcat
> 5.0.19
> (javaEncoding is UTF-8 by default). pageEncoding
> controls the way Tomcat reads the source file, but
> it's useless with the <%@include directive. And, of
> course, there can be only one <%@ page directive, at
> the "root" JSP page.
> 
> By the way, I cannot find the Class who controls
> this
> tag at cvs.apache.org (this is a gigantic project!),
> any clues?
> 
>  --- Mike Curwen <gb...@gb-im.com> wrote: > So:
> >  <%@ page pageEncoding="utf-8" %>
> >  
> > would be the correct way to handle the case of
> > including files with
> > utf-8 characters, except Tomcat ignores
> > pageEncoding? (for all files?
> > for non-JSP files?)
> >  
> > 
> > 
> > > -----Original Message-----
> > > From: Ivan Montoro
> > [mailto:ivan_montoro_ten@yahoo.es] 
> > > Sent: Monday, April 05, 2004 12:07 PM
> > > To: Tomcat Users List
> > > Subject: RE: JSP include directive and UTF-8
> files
> > in Tomcat 5
> > > 
> > > 
> > > Hi Mike,
> > > 
> > > Nope, pageEncoding does not work either. JSP
> > syntax
> > > 1.2
> > >
> >
>
(http://java.sun.com/products/jsp/syntax/1.2/syntaxref1210.htm
> > > l#1001361)
> > > stands that this is the "page source character
> > > encoding", and javaEncoding at web.xml controls
> > the
> > > encoding for resulting .java files at work/
> > directory.
> > > I'm afraid this is a bug in the <%@include JSP
> > > implementation, opening all files in ISO-8859-1.
> > > 
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> >  
> 
> ___________________________________________________
> Yahoo! Messenger - Nueva versión GRATIS
> Super Webcam, voz, caritas animadas, y más...
> http://messenger.yahoo.es
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
>  

___________________________________________________
Yahoo! Messenger - Nueva versión GRATIS
Super Webcam, voz, caritas animadas, y más...
http://messenger.yahoo.es

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


RE: JSP include directive and UTF-8 files in Tomcat 5

Posted by Yansheng Lin <ya...@silvacom.com>.
>And, of
>course, there can be only one <%@ page directive, at
>the "root" JSP page.

um, might not understand you correctly.  you can have as many as you want
actually.
i.e., <%@ page pageEncoding="utf-8" %>
	<%@ page contentType="text/html;charset=utf-8" %>
	<%@ page import="myOwnClass" %>
	...

Hope this helps:).

-Yan

-----Original Message-----
From: Ivan Montoro [mailto:ivan_montoro_ten@yahoo.es] 
Sent: Monday, April 05, 2004 11:33 AM
To: Tomcat Users List
Subject: RE: JSP include directive and UTF-8 files in Tomcat 5


The fact is that all JSP pages are created in the
work/ directory in UTF-8, at least with Tomcat 5.0.19
(javaEncoding is UTF-8 by default). pageEncoding
controls the way Tomcat reads the source file, but
it's useless with the <%@include directive. And, of
course, there can be only one <%@ page directive, at
the "root" JSP page.

By the way, I cannot find the Class who controls this
tag at cvs.apache.org (this is a gigantic project!),
any clues?

 --- Mike Curwen <gb...@gb-im.com> wrote: > So:
>  <%@ page pageEncoding="utf-8" %>
>  
> would be the correct way to handle the case of
> including files with
> utf-8 characters, except Tomcat ignores
> pageEncoding? (for all files?
> for non-JSP files?)
>  
> 
> 
> > -----Original Message-----
> > From: Ivan Montoro
> [mailto:ivan_montoro_ten@yahoo.es] 
> > Sent: Monday, April 05, 2004 12:07 PM
> > To: Tomcat Users List
> > Subject: RE: JSP include directive and UTF-8 files
> in Tomcat 5
> > 
> > 
> > Hi Mike,
> > 
> > Nope, pageEncoding does not work either. JSP
> syntax
> > 1.2
> >
>
(http://java.sun.com/products/jsp/syntax/1.2/syntaxref1210.htm
> > l#1001361)
> > stands that this is the "page source character
> > encoding", and javaEncoding at web.xml controls
> the
> > encoding for resulting .java files at work/
> directory.
> > I'm afraid this is a bug in the <%@include JSP
> > implementation, opening all files in ISO-8859-1.
> > 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
>  

___________________________________________________
Yahoo! Messenger - Nueva versión GRATIS
Super Webcam, voz, caritas animadas, y más...
http://messenger.yahoo.es

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


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


RE: JSP include directive and UTF-8 files in Tomcat 5

Posted by Ivan Montoro <iv...@yahoo.es>.
The fact is that all JSP pages are created in the
work/ directory in UTF-8, at least with Tomcat 5.0.19
(javaEncoding is UTF-8 by default). pageEncoding
controls the way Tomcat reads the source file, but
it's useless with the <%@include directive. And, of
course, there can be only one <%@ page directive, at
the "root" JSP page.

By the way, I cannot find the Class who controls this
tag at cvs.apache.org (this is a gigantic project!),
any clues?

 --- Mike Curwen <gb...@gb-im.com> wrote: > So:
>  <%@ page pageEncoding="utf-8" %>
>  
> would be the correct way to handle the case of
> including files with
> utf-8 characters, except Tomcat ignores
> pageEncoding? (for all files?
> for non-JSP files?)
>  
> 
> 
> > -----Original Message-----
> > From: Ivan Montoro
> [mailto:ivan_montoro_ten@yahoo.es] 
> > Sent: Monday, April 05, 2004 12:07 PM
> > To: Tomcat Users List
> > Subject: RE: JSP include directive and UTF-8 files
> in Tomcat 5
> > 
> > 
> > Hi Mike,
> > 
> > Nope, pageEncoding does not work either. JSP
> syntax
> > 1.2
> >
>
(http://java.sun.com/products/jsp/syntax/1.2/syntaxref1210.htm
> > l#1001361)
> > stands that this is the "page source character
> > encoding", and javaEncoding at web.xml controls
> the
> > encoding for resulting .java files at work/
> directory.
> > I'm afraid this is a bug in the <%@include JSP
> > implementation, opening all files in ISO-8859-1.
> > 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
>  

___________________________________________________
Yahoo! Messenger - Nueva versión GRATIS
Super Webcam, voz, caritas animadas, y más...
http://messenger.yahoo.es

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


RE: JSP include directive and UTF-8 files in Tomcat 5

Posted by Mike Curwen <gb...@gb-im.com>.
So:
 <%@ page pageEncoding="utf-8" %>
 
would be the correct way to handle the case of including files with
utf-8 characters, except Tomcat ignores pageEncoding? (for all files?
for non-JSP files?)
 


> -----Original Message-----
> From: Ivan Montoro [mailto:ivan_montoro_ten@yahoo.es] 
> Sent: Monday, April 05, 2004 12:07 PM
> To: Tomcat Users List
> Subject: RE: JSP include directive and UTF-8 files in Tomcat 5
> 
> 
> Hi Mike,
> 
> Nope, pageEncoding does not work either. JSP syntax
> 1.2
> (http://java.sun.com/products/jsp/syntax/1.2/syntaxref1210.htm
> l#1001361)
> stands that this is the "page source character
> encoding", and javaEncoding at web.xml controls the
> encoding for resulting .java files at work/ directory.
> I'm afraid this is a bug in the <%@include JSP
> implementation, opening all files in ISO-8859-1.
> 


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


RE: JSP include directive and UTF-8 files in Tomcat 5

Posted by Ivan Montoro <iv...@yahoo.es>.
Hi Mike,

Nope, pageEncoding does not work either. JSP syntax
1.2
(http://java.sun.com/products/jsp/syntax/1.2/syntaxref1210.html#1001361)
stands that this is the "page source character
encoding", and javaEncoding at web.xml controls the
encoding for resulting .java files at work/ directory.
I'm afraid this is a bug in the <%@include JSP
implementation, opening all files in ISO-8859-1.

 --- Mike Curwen <gb...@gb-im.com> wrote: > 
> <%@ page	
>    [ contentType="mimeType [ ; charset=characterSet
> ]" |	
>       "text/html ; charset=ISO-8859-1" ]	
>    [ pageEncoding="characterSet | ISO-8859-1" ]	
> %>
> 
> 
> you have the contentType (which maybe is for the
> browser?) but not the
> pageEncoding (which is maybe for Tomcat?)
>  
> I'm just guessing though.
> 
> > -----Original Message-----
> > From: Ivan Montoro
> [mailto:ivan_montoro_ten@yahoo.es] 
> > Sent: Sunday, April 04, 2004 2:14 PM
> > To: tomcat-user@jakarta.apache.org
> > Subject: JSP include directive and UTF-8 files in
> Tomcat 5
> > 
> > 
> > Hi everybody,
> > 
> > I've found that with the default installation of
> > Jakarta Tomcat 5.0.19, JSP include directive fails
> to
> > add UTF-8 files to the generated .java source
> file. If
> > you create a simple .jsp file with a <%@include
> > directive, and include an HTML file saved as
> UTF-8,
> > the resulting .java file contains the UTF-8
> > representation of the ISO-8859-1 characters.
> > 
> > I'm using the Unix "file" tool to see if the files
> > I have are UTF-8 or not, so that's clear. I've
> > tried the -Dfile.encoding=UTF-8 at setenv.sh and
> > javaEncoding property in web.xml with no result.
> > 
> > -------------------------------------------------
> > sample.jsp (UTF-8)
> > -------------------------------------------------
> > <%@ page contentType="text/html;charset=UTF-8" %> 
> > <HTML><HEAD></HEAD><BODY> hellô wórld! <%@ include
> 
> > file="sample.html" %> </BODY></HTML>
> > -------------------------------------------------
> > sample.html (UTF-8)
> > -------------------------------------------------
> > fóò bär
> > -------------------------------------------------
> > resulting file (sample_jsp.java at work/ folder)
> > -------------------------------------------------
> > [...]
> >       out.write("<HTML><HEAD></HEAD><BODY>\n");
> >       out.write("hellô wórld!\n");
> >       out.write("fóò bär\n");
> >       out.write("</BODY></HTML>\n");
> > [...]
> > -------------------------------------------------
> > output in the browser
> > -------------------------------------------------
> > hellô wórld! fóò bär
> > -------------------------------------------------
> > using "iconv -t ISO-8859-1" to convert .java file
> > -------------------------------------------------
> >       out.write("<HTML><HEAD></HEAD><BODY>\n");
> >       out.write("hell wrld!\n");
> >       out.write("fóò bär\n");
> >       out.write("</BODY></HTML>\n");
> > -------------------------------------------------
> > 
> > So, I believe that when you make a <%@include in
> > Tomcat 5, the file is opened and read in
> ISO-8859-1
> > encoding and then added to the .java source and
> > compiled. I'm right? Is there any way to tell
> Tomcat
> > to load files from <%@include in UTF-8?
> > 
> > Thanks!
> > 
> > Ivan
> > 
> >
> ___________________________________________________
> > Yahoo! Messenger - Nueva versión GRATIS
> > Super Webcam, voz, caritas animadas, y más... 
> > http://messenger.yahoo.es
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> > 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
>  

___________________________________________________
Yahoo! Messenger - Nueva versión GRATIS
Super Webcam, voz, caritas animadas, y más...
http://messenger.yahoo.es

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


RE: JSP include directive and UTF-8 files in Tomcat 5

Posted by Mike Curwen <gb...@gb-im.com>.
<%@ page	
   [ contentType="mimeType [ ; charset=characterSet ]" |	
      "text/html ; charset=ISO-8859-1" ]	
   [ pageEncoding="characterSet | ISO-8859-1" ]	
%>


you have the contentType (which maybe is for the browser?) but not the
pageEncoding (which is maybe for Tomcat?)
 
I'm just guessing though.

> -----Original Message-----
> From: Ivan Montoro [mailto:ivan_montoro_ten@yahoo.es] 
> Sent: Sunday, April 04, 2004 2:14 PM
> To: tomcat-user@jakarta.apache.org
> Subject: JSP include directive and UTF-8 files in Tomcat 5
> 
> 
> Hi everybody,
> 
> I've found that with the default installation of
> Jakarta Tomcat 5.0.19, JSP include directive fails to
> add UTF-8 files to the generated .java source file. If
> you create a simple .jsp file with a <%@include
> directive, and include an HTML file saved as UTF-8,
> the resulting .java file contains the UTF-8
> representation of the ISO-8859-1 characters.
> 
> I'm using the Unix "file" tool to see if the files
> I have are UTF-8 or not, so that's clear. I've
> tried the -Dfile.encoding=UTF-8 at setenv.sh and
> javaEncoding property in web.xml with no result.
> 
> -------------------------------------------------
> sample.jsp (UTF-8)
> -------------------------------------------------
> <%@ page contentType="text/html;charset=UTF-8" %> 
> <HTML><HEAD></HEAD><BODY> hellô wórld! <%@ include 
> file="sample.html" %> </BODY></HTML>
> -------------------------------------------------
> sample.html (UTF-8)
> -------------------------------------------------
> fóò bär
> -------------------------------------------------
> resulting file (sample_jsp.java at work/ folder)
> -------------------------------------------------
> [...]
>       out.write("<HTML><HEAD></HEAD><BODY>\n");
>       out.write("hellô wórld!\n");
>       out.write("fóò bär\n");
>       out.write("</BODY></HTML>\n");
> [...]
> -------------------------------------------------
> output in the browser
> -------------------------------------------------
> hellô wórld! fóò bär
> -------------------------------------------------
> using "iconv -t ISO-8859-1" to convert .java file
> -------------------------------------------------
>       out.write("<HTML><HEAD></HEAD><BODY>\n");
>       out.write("hell wrld!\n");
>       out.write("fóò bär\n");
>       out.write("</BODY></HTML>\n");
> -------------------------------------------------
> 
> So, I believe that when you make a <%@include in
> Tomcat 5, the file is opened and read in ISO-8859-1
> encoding and then added to the .java source and
> compiled. I'm right? Is there any way to tell Tomcat
> to load files from <%@include in UTF-8?
> 
> Thanks!
> 
> Ivan
> 
> ___________________________________________________
> Yahoo! Messenger - Nueva versión GRATIS
> Super Webcam, voz, caritas animadas, y más... 
> http://messenger.yahoo.es
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


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