You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by eMantra Information <em...@emantratech.com> on 2004/04/03 09:03:34 UTC

FW: jsp:include tag does not preserve encoding of the text


hi

I am using Apache web server and Tomcat 4.1.

I have a jsp:include tag (in say test1.jsp) and I am trying to include a data1.html file. This html file contains UTF-8 encoded text. When this JSP is executed, the UTF-8 text is displayed as garbage characters.


I have included following in the JSP
<%@ page contentType="text/html; charset=UTF-8" %> 


I have included following in the info.html
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">

However if I rename the info.html to data1.jsp and then include, the UTF-8 text gets displayed correctly.

I suppose, the JSP engine does not interprete the content of the html file correctly according to its encoding.
Where as if it is a .jsp, then it is int erpreting it appropriately?

Can anybody throw some lite on this?


regards
haresh
////////////////////////////////////////////////////////////////////////////////////
sample files.......

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

<% 

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

%>



<HTML>

<HEAD>

<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">

</HEAD>

<BODY>

<jsp:include page="data1.html" flush="true"/>

</BODY>

</HTML>

////////////////////////////////////////////////////////////////////////////////////
data1.html.....

<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<br>
हाती घ्याल ते तडीस न्या.
<br>


RE: FW: jsp:include tag does not preserve encoding of the text

Posted by Yansheng Lin <ya...@silvacom.com>.
Agreed!  
Hey, one way I can think of to solve your problem is to use a jsp file instead of html page.  That way you can set the pageEncoding to be utf-8.  That should take care of it.  Also I read it somewhere that it's always better to use jsp pages, not sure why though.  Something to do with how the container handles different types.

-Yan

-----Original Message-----
From: Hiroshi Iwatani [mailto:HGA03630@nifty.ne.jp] 
Sent: Saturday, April 03, 2004 3:40 AM
To: Tomcat Users List
Subject: Re: FW: jsp:include tag does not preserve encoding of the text


In your deployment, html is handled by Apache and not processed by JSP/Servlet
engine. Included JSP inherit main-page setting. If you run Tomcat stand-alone
without other HTTP server, you will find its html handling characteristics.
I don't expect much from Tomcat, though ;-)

eMantra Information wrote:
> 
> hi
> 
> I am using Apache web server and Tomcat 4.1.
> 
> I have a jsp:include tag (in say test1.jsp) and I am trying to include a data1.html file. This html file contains UTF-8 encoded text. When this JSP is executed, the UTF-8 text is displayed as garbage characters.
> 
> 
> I have included following in the JSP
> <%@ page contentType="text/html; charset=UTF-8" %> 
> 
> 
> I have included following in the info.html
> <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
> 
> However if I rename the info.html to data1.jsp and then include, the UTF-8 text gets displayed correctly.
> 
> I suppose, the JSP engine does not interprete the content of the html file correctly according to its encoding.
> Where as if it is a .jsp, then it is int erpreting it appropriately?
> 
> Can anybody throw some lite on this?
> 
> 
> regards
> haresh
> ////////////////////////////////////////////////////////////////////////////////////
> sample files.......
> 
> ////////////////////////////////////////////////////////////////////////////////////
> test1.jsp..........
> <%@ page contentType="text/html; charset=UTF-8" %> 
> 
> <% 
> 
> response.setContentType("text/html; charset=UTF-8");
> 
> %>
> 
> 
> 
> <HTML>
> 
> <HEAD>
> 
> <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
> 
> </HEAD>
> 
> <BODY>
> 
> <jsp:include page="data1.html" flush="true"/>
> 
> </BODY>
> 
> </HTML>
> 
> ////////////////////////////////////////////////////////////////////////////////////
> data1.html.....
> 
> <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
> <br>
> हाती घ्याल ते तडीस न्या.
> <br>
> 
> 

-- 
Hiroshi Iwatani

*stop cruelty* Annual number of institutionally euthanized cats and dogs 
including kittens and puppies: US 5 million, JP 500 thousand. How about your 
country? *for our better karma*
---------------------

---------------------------------------------------------------------
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: FW: jsp:include tag does not preserve encoding of the text

Posted by Hiroshi Iwatani <HG...@nifty.ne.jp>.
In your deployment, html is handled by Apache and not processed by JSP/Servlet
engine. Included JSP inherit main-page setting. If you run Tomcat stand-alone
without other HTTP server, you will find its html handling characteristics.
I don't expect much from Tomcat, though ;-)

eMantra Information wrote:
> 
> hi
> 
> I am using Apache web server and Tomcat 4.1.
> 
> I have a jsp:include tag (in say test1.jsp) and I am trying to include a data1.html file. This html file contains UTF-8 encoded text. When this JSP is executed, the UTF-8 text is displayed as garbage characters.
> 
> 
> I have included following in the JSP
> <%@ page contentType="text/html; charset=UTF-8" %> 
> 
> 
> I have included following in the info.html
> <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
> 
> However if I rename the info.html to data1.jsp and then include, the UTF-8 text gets displayed correctly.
> 
> I suppose, the JSP engine does not interprete the content of the html file correctly according to its encoding.
> Where as if it is a .jsp, then it is int erpreting it appropriately?
> 
> Can anybody throw some lite on this?
> 
> 
> regards
> haresh
> ////////////////////////////////////////////////////////////////////////////////////
> sample files.......
> 
> ////////////////////////////////////////////////////////////////////////////////////
> test1.jsp..........
> <%@ page contentType="text/html; charset=UTF-8" %> 
> 
> <% 
> 
> response.setContentType("text/html; charset=UTF-8");
> 
> %>
> 
> 
> 
> <HTML>
> 
> <HEAD>
> 
> <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
> 
> </HEAD>
> 
> <BODY>
> 
> <jsp:include page="data1.html" flush="true"/>
> 
> </BODY>
> 
> </HTML>
> 
> ////////////////////////////////////////////////////////////////////////////////////
> data1.html.....
> 
> <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
> <br>
> हाती घ्याल ते तडीस न्या.
> <br>
> 
> 

-- 
Hiroshi Iwatani

*stop cruelty* Annual number of institutionally euthanized cats and dogs 
including kittens and puppies: US 5 million, JP 500 thousand. How about your 
country? *for our better karma*
---------------------

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