You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Ruth, Brice" <br...@fiskars.com> on 2004/06/10 21:59:41 UTC

Corrupted UTF-8 JSPs?!

I'm running into a strange issue.

I have certain JSPs with UTF-8 encoded characters in them (polish 
characters, to be exact). My Ant build.xml precompiles the JSPs using 
Jasper and then packages the application into a WAR for deployment.

When I develop locally with Tomcat 5.0.18, I deploy without packaging 
into a WAR first. However, to deploy remotely, I create a WAR, then 
deploy from that.

Locally, the JSPs appear just as they should. After being packaged into 
a WAR (even if I deploy it locally to the exact same instance of Tomcat 
5.0.18), the UTF-8 characters are garbaged up. The garbaging appears the 
same as it does when I override the page-provided UTF-8 encoding (in the 
browser) and manually set the encoding to ISO-8859-1.

What's going on here?! By the time that the JSPs are added to the WAR, 
they're binary .class files, since they are precompiled! Text encodings 
shouldn't make a bit of difference at that point, should they?!?

The JSPs loaded still tell the browser that the encoding is UTF-8 ... 
and UTF-8 characters in the .properties files (passed through 
native2ascii) are properly displayed.

It seems to me that something very strange is going on ... moreover, 
this is going to really throw a wrench in our project if we can't get to 
the bottom of it!

Respectfully,
Brice Ruth

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


Directory Structure Problems

Posted by "Val T." <vt...@realityclick.com>.
Hi,

I've encountered a difficulty in a web site implementation, which uses
Tomcat 4.1.18 on RH Linux 8.0, MySQL 3.23.54, J2SDK 1.4.1_01, and connection
pooling with Form based authentication.  Everything was working fine, until
some tweaks were done to the proxy server.

The directory strucuture is as follows:

CATALINA_HOME/webapps/LiveSite/Restricted
CATALINA_HOME/webapps/LiveSite/[main files and folders]
CATALINA_HOME/webapps/LiveSite/Login/login.jsp

I'm told that there is an Apache proxy server set up, that forwards the
requests to Tomcat.  When it was originally set up, requests that came in
for www.companyName.com would be redirected to the LiveSite folder, and the
index.jsp page was served up.  I noticed that the URL in the browser would
display the "LiveSite" folder in the address bar, after www.companyName.com,
like this:

www.companyName.com/LiveSite/index.jsp.

After some tweaks were done on the proxy server, the LiveSite folder no
longer displays in the address bar.  As a matter of fact, if you include it,
you get a 404 page not found error.  This would all be fine, and an
improvement, since it hides the directory structure, if it weren't for what
it has done to the authentication process.  Everything under the Restricted
folder requires login.  So, when everything was working, a person would
login, and, once authenticated, they would be able to happily do their thing
in that admin area.

Now, however, they can login in (usually after three attempts), but the
stylesheets are no longer recognized, the javascripts are not recognized,
images are broken, and if you click on a link, you are presented with the
login screen again.  There seems to be domain/directory structure confusion
in the server.

My problem is that I don't know which server is confused.  I think that this
LiveSite folder is now the default root folder.  I tried to set this as such
in the server.xml file in Tomcat, to see if that would help.

So, whereas I'd had the context as this:

<Context path="/LiveSite" docBase="LiveSite" debug="0" reloadable="true" >

I tried changing it to this:
<Context path="" docBase="LiveSite" debug="0" reloadable="true" >

This at first looked like a good move, until I discovered that doing this
gave me the following error:

java.sql.SQLException: Cannot load JDBC driver class 'null'

so I've put it back the way I had it.  At least people can view the site,
though they can't use the restricted admin area, because they keep getting
the login page coming up.  It's like the session is lost, but the log files
in Tomcat don't show an error.

In the web.xml file for the site, this is what I have for the security
constraint on the restricted folder:

<security-constraint>
  <web-resource-collection>
   <web-resource-name>Admin</web-resource-name>
   <!-- Define the context-relative URL(s) to be protected -->
   <url-pattern>/Restricted/*</url-pattern>
   snip...
  </web-resource-collection>
  <auth-constraint>
   <description>only let the admin users login</description>
   <role-name>role1</role-name>
   <role-name>role2</role-name>
  </auth-constraint>
 </security-constraint>

Since the problems started with tweaks that were done on the proxy server, I
think we should be looking there.  But I've been told that the problem is
probably with the site or Tomcat.  However, all of the documentation that
I've read, and the searching I've done in the archives, has brought me to a
dead end.  And I still think there must be something that either should be
done in Tomcat to accommodate the fact that requests are going through a
proxy (though the same settings that I've got on this site work on other
sites that are on the same server--they're just not the default sites), or
there should be something done to the proxy itself.

I have been searching for a solution for two days, and don't know what
direction to go in.  The Tomcat logs don't indicate that there is a problem
at all, unless I have the context path as "", and searching on the
SQLException didn't get me anywhere.

If anyone can give me a direction to look, I'd be really grateful.

Thanks for any help.

Val


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


Re: Corrupted UTF-8 JSPs?!

Posted by "Ruth, Brice" <br...@fiskars.com>.
Thanks much! The following article was very informative:

http://www.javaworld.com/javaworld/jw-04-2004/jw-0419-multibytes_p.html

adding 'encoding="UTF-8"' to my JAVAC tasks in my Ant's build.xml seemed 
to have taken care of the problem I was seeing. The article was 
informative in many other ways, too. Great article, thanks!

Vernon wrote:

>There are two recent related articles on Javaworld.
>They may help you in this regards.
>
>--- "Ruth, Brice" <br...@fiskars.com> wrote:
>  
>
>>I'm running into a strange issue.
>>
>>I have certain JSPs with UTF-8 encoded characters in
>>them (polish 
>>characters, to be exact). My Ant build.xml
>>precompiles the JSPs using 
>>Jasper and then packages the application into a WAR
>>for deployment.
>>
>>When I develop locally with Tomcat 5.0.18, I deploy
>>without packaging 
>>into a WAR first. However, to deploy remotely, I
>>create a WAR, then 
>>deploy from that.
>>
>>Locally, the JSPs appear just as they should. After
>>being packaged into 
>>a WAR (even if I deploy it locally to the exact same
>>instance of Tomcat 
>>5.0.18), the UTF-8 characters are garbaged up. The
>>garbaging appears the 
>>same as it does when I override the page-provided
>>UTF-8 encoding (in the 
>>browser) and manually set the encoding to
>>ISO-8859-1.
>>
>>What's going on here?! By the time that the JSPs are
>>added to the WAR, 
>>they're binary .class files, since they are
>>precompiled! Text encodings 
>>shouldn't make a bit of difference at that point,
>>should they?!?
>>
>>The JSPs loaded still tell the browser that the
>>encoding is UTF-8 ... 
>>and UTF-8 characters in the .properties files
>>(passed through 
>>native2ascii) are properly displayed.
>>
>>It seems to me that something very strange is going
>>on ... moreover, 
>>this is going to really throw a wrench in our
>>project if we can't get to 
>>the bottom of it!
>>
>>Respectfully,
>>Brice Ruth
>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail:
>>tomcat-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>
>	
>		
>__________________________________
>Do you Yahoo!?
>Friends.  Fun.  Try the all-new Yahoo! Messenger.
>http://messenger.yahoo.com/ 
>
>---------------------------------------------------------------------
>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: Corrupted UTF-8 JSPs?!

Posted by Vernon <vw...@yahoo.com>.
There are two recent related articles on Javaworld.
They may help you in this regards.

--- "Ruth, Brice" <br...@fiskars.com> wrote:
> I'm running into a strange issue.
> 
> I have certain JSPs with UTF-8 encoded characters in
> them (polish 
> characters, to be exact). My Ant build.xml
> precompiles the JSPs using 
> Jasper and then packages the application into a WAR
> for deployment.
> 
> When I develop locally with Tomcat 5.0.18, I deploy
> without packaging 
> into a WAR first. However, to deploy remotely, I
> create a WAR, then 
> deploy from that.
> 
> Locally, the JSPs appear just as they should. After
> being packaged into 
> a WAR (even if I deploy it locally to the exact same
> instance of Tomcat 
> 5.0.18), the UTF-8 characters are garbaged up. The
> garbaging appears the 
> same as it does when I override the page-provided
> UTF-8 encoding (in the 
> browser) and manually set the encoding to
> ISO-8859-1.
> 
> What's going on here?! By the time that the JSPs are
> added to the WAR, 
> they're binary .class files, since they are
> precompiled! Text encodings 
> shouldn't make a bit of difference at that point,
> should they?!?
> 
> The JSPs loaded still tell the browser that the
> encoding is UTF-8 ... 
> and UTF-8 characters in the .properties files
> (passed through 
> native2ascii) are properly displayed.
> 
> It seems to me that something very strange is going
> on ... moreover, 
> this is going to really throw a wrench in our
> project if we can't get to 
> the bottom of it!
> 
> Respectfully,
> Brice Ruth
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

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


Re: Corrupted UTF-8 JSPs?!

Posted by "Ruth, Brice" <br...@fiskars.com>.
Everything is being created through Ant - the problem appeared to be 
resolved when I modified the javac task to use UTF-8 encoding, though 
I'm still not clear on why this issue would only be visible when the 
files go through the WAR/JAR process first. Very unclear on that. But, 
the problem appears to be fixed.

Yansheng Lin wrote:

>How did you create your war file then?  Through an IDE?
>
>I looked up the man page for 'jar' command.  It's pretty straight-forward.
>Are you compressing your class files?  That may modify the content of the
>files.
>
>Hope it helps
>
>Yan
>
>-----Original Message-----
>From: Ruth, Brice [mailto:bruth@fiskars.com] 
>Sent: June 10, 2004 15:20
>To: Tomcat Users List
>Subject: Re: Corrupted UTF-8 JSPs?!
>
>
>Thanks, but I believe the problem is in the WAR packaging, somehow ... 
>because I develop locally, deploy w/o packaging and it works fine - if I 
>package it up again and re-deploy LOCALLY, then I get garbage ...
>
>native2ascii only works for properties files, as far as I've been able 
>to determine. UTF-8 encoded JSPs have to have UTF-8 encoded characters, 
>not the \u escaped characters that native2ascii creates. We only use 
>native2ascii for our properties files
>
>Yansheng Lin wrote:
>
>  
>
>>"developed locally, and then deployed remotely"
>>
>>Make sure on the remote system, the Java Runtime Environment supports UTF-8
>>and is using it as the default encoding(export
>>JAVA_OPTS=-Dfile.encoding="utf8").  
>>
>>native2ascii UTF-8 encoded characters may help too.
>>
>>Yan
>>
>>-----Original Message-----
>>From: Ruth, Brice [mailto:bruth@fiskars.com] 
>>Sent: June 10, 2004 14:00
>>To: Tomcat Users List
>>Subject: Corrupted UTF-8 JSPs?!
>>
>>
>>I'm running into a strange issue.
>>
>>I have certain JSPs with UTF-8 encoded characters in them (polish 
>>characters, to be exact). My Ant build.xml precompiles the JSPs using 
>>Jasper and then packages the application into a WAR for deployment.
>>
>>When I develop locally with Tomcat 5.0.18, I deploy without packaging 
>>into a WAR first. However, to deploy remotely, I create a WAR, then 
>>deploy from that.
>>
>>Locally, the JSPs appear just as they should. After being packaged into 
>>a WAR (even if I deploy it locally to the exact same instance of Tomcat 
>>5.0.18), the UTF-8 characters are garbaged up. The garbaging appears the 
>>same as it does when I override the page-provided UTF-8 encoding (in the 
>>browser) and manually set the encoding to ISO-8859-1.
>>
>>What's going on here?! By the time that the JSPs are added to the WAR, 
>>they're binary .class files, since they are precompiled! Text encodings 
>>shouldn't make a bit of difference at that point, should they?!?
>>
>>The JSPs loaded still tell the browser that the encoding is UTF-8 ... 
>>and UTF-8 characters in the .properties files (passed through 
>>native2ascii) are properly displayed.
>>
>>It seems to me that something very strange is going on ... moreover, 
>>this is going to really throw a wrench in our project if we can't get to 
>>the bottom of it!
>>
>>Respectfully,
>>Brice Ruth
>>
>>---------------------------------------------------------------------
>>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
>>
>> 
>>
>>    
>>
>
>---------------------------------------------------------------------
>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
>
>  
>

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


RE: Corrupted UTF-8 JSPs?!

Posted by Yansheng Lin <ya...@silvacom.com>.
How did you create your war file then?  Through an IDE?

I looked up the man page for 'jar' command.  It's pretty straight-forward.
Are you compressing your class files?  That may modify the content of the
files.

Hope it helps

Yan

-----Original Message-----
From: Ruth, Brice [mailto:bruth@fiskars.com] 
Sent: June 10, 2004 15:20
To: Tomcat Users List
Subject: Re: Corrupted UTF-8 JSPs?!


Thanks, but I believe the problem is in the WAR packaging, somehow ... 
because I develop locally, deploy w/o packaging and it works fine - if I 
package it up again and re-deploy LOCALLY, then I get garbage ...

native2ascii only works for properties files, as far as I've been able 
to determine. UTF-8 encoded JSPs have to have UTF-8 encoded characters, 
not the \u escaped characters that native2ascii creates. We only use 
native2ascii for our properties files

Yansheng Lin wrote:

>"developed locally, and then deployed remotely"
>
>Make sure on the remote system, the Java Runtime Environment supports UTF-8
>and is using it as the default encoding(export
>JAVA_OPTS=-Dfile.encoding="utf8").  
>
>native2ascii UTF-8 encoded characters may help too.
>
>Yan
>
>-----Original Message-----
>From: Ruth, Brice [mailto:bruth@fiskars.com] 
>Sent: June 10, 2004 14:00
>To: Tomcat Users List
>Subject: Corrupted UTF-8 JSPs?!
>
>
>I'm running into a strange issue.
>
>I have certain JSPs with UTF-8 encoded characters in them (polish 
>characters, to be exact). My Ant build.xml precompiles the JSPs using 
>Jasper and then packages the application into a WAR for deployment.
>
>When I develop locally with Tomcat 5.0.18, I deploy without packaging 
>into a WAR first. However, to deploy remotely, I create a WAR, then 
>deploy from that.
>
>Locally, the JSPs appear just as they should. After being packaged into 
>a WAR (even if I deploy it locally to the exact same instance of Tomcat 
>5.0.18), the UTF-8 characters are garbaged up. The garbaging appears the 
>same as it does when I override the page-provided UTF-8 encoding (in the 
>browser) and manually set the encoding to ISO-8859-1.
>
>What's going on here?! By the time that the JSPs are added to the WAR, 
>they're binary .class files, since they are precompiled! Text encodings 
>shouldn't make a bit of difference at that point, should they?!?
>
>The JSPs loaded still tell the browser that the encoding is UTF-8 ... 
>and UTF-8 characters in the .properties files (passed through 
>native2ascii) are properly displayed.
>
>It seems to me that something very strange is going on ... moreover, 
>this is going to really throw a wrench in our project if we can't get to 
>the bottom of it!
>
>Respectfully,
>Brice Ruth
>
>---------------------------------------------------------------------
>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
>
>  
>

---------------------------------------------------------------------
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: Corrupted UTF-8 JSPs?!

Posted by "Ruth, Brice" <br...@fiskars.com>.
Thanks, but I believe the problem is in the WAR packaging, somehow ... 
because I develop locally, deploy w/o packaging and it works fine - if I 
package it up again and re-deploy LOCALLY, then I get garbage ...

native2ascii only works for properties files, as far as I've been able 
to determine. UTF-8 encoded JSPs have to have UTF-8 encoded characters, 
not the \u escaped characters that native2ascii creates. We only use 
native2ascii for our properties files

Yansheng Lin wrote:

>"developed locally, and then deployed remotely"
>
>Make sure on the remote system, the Java Runtime Environment supports UTF-8
>and is using it as the default encoding(export
>JAVA_OPTS=-Dfile.encoding="utf8").  
>
>native2ascii UTF-8 encoded characters may help too.
>
>Yan
>
>-----Original Message-----
>From: Ruth, Brice [mailto:bruth@fiskars.com] 
>Sent: June 10, 2004 14:00
>To: Tomcat Users List
>Subject: Corrupted UTF-8 JSPs?!
>
>
>I'm running into a strange issue.
>
>I have certain JSPs with UTF-8 encoded characters in them (polish 
>characters, to be exact). My Ant build.xml precompiles the JSPs using 
>Jasper and then packages the application into a WAR for deployment.
>
>When I develop locally with Tomcat 5.0.18, I deploy without packaging 
>into a WAR first. However, to deploy remotely, I create a WAR, then 
>deploy from that.
>
>Locally, the JSPs appear just as they should. After being packaged into 
>a WAR (even if I deploy it locally to the exact same instance of Tomcat 
>5.0.18), the UTF-8 characters are garbaged up. The garbaging appears the 
>same as it does when I override the page-provided UTF-8 encoding (in the 
>browser) and manually set the encoding to ISO-8859-1.
>
>What's going on here?! By the time that the JSPs are added to the WAR, 
>they're binary .class files, since they are precompiled! Text encodings 
>shouldn't make a bit of difference at that point, should they?!?
>
>The JSPs loaded still tell the browser that the encoding is UTF-8 ... 
>and UTF-8 characters in the .properties files (passed through 
>native2ascii) are properly displayed.
>
>It seems to me that something very strange is going on ... moreover, 
>this is going to really throw a wrench in our project if we can't get to 
>the bottom of it!
>
>Respectfully,
>Brice Ruth
>
>---------------------------------------------------------------------
>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
>
>  
>

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


RE: Corrupted UTF-8 JSPs?!

Posted by Yansheng Lin <ya...@silvacom.com>.
"developed locally, and then deployed remotely"

Make sure on the remote system, the Java Runtime Environment supports UTF-8
and is using it as the default encoding(export
JAVA_OPTS=-Dfile.encoding="utf8").  

native2ascii UTF-8 encoded characters may help too.

Yan

-----Original Message-----
From: Ruth, Brice [mailto:bruth@fiskars.com] 
Sent: June 10, 2004 14:00
To: Tomcat Users List
Subject: Corrupted UTF-8 JSPs?!


I'm running into a strange issue.

I have certain JSPs with UTF-8 encoded characters in them (polish 
characters, to be exact). My Ant build.xml precompiles the JSPs using 
Jasper and then packages the application into a WAR for deployment.

When I develop locally with Tomcat 5.0.18, I deploy without packaging 
into a WAR first. However, to deploy remotely, I create a WAR, then 
deploy from that.

Locally, the JSPs appear just as they should. After being packaged into 
a WAR (even if I deploy it locally to the exact same instance of Tomcat 
5.0.18), the UTF-8 characters are garbaged up. The garbaging appears the 
same as it does when I override the page-provided UTF-8 encoding (in the 
browser) and manually set the encoding to ISO-8859-1.

What's going on here?! By the time that the JSPs are added to the WAR, 
they're binary .class files, since they are precompiled! Text encodings 
shouldn't make a bit of difference at that point, should they?!?

The JSPs loaded still tell the browser that the encoding is UTF-8 ... 
and UTF-8 characters in the .properties files (passed through 
native2ascii) are properly displayed.

It seems to me that something very strange is going on ... moreover, 
this is going to really throw a wrench in our project if we can't get to 
the bottom of it!

Respectfully,
Brice Ruth

---------------------------------------------------------------------
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