tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hiroshi Iwatani <>
Subject Re: JSP Include and URL encoding
Date Fri, 02 Apr 2004 09:34:34 GMT
(1)Set page directive attributes right
    (Maybe, pageEncoding = your platform encoding and charset = UTF-8)
(2)Use a Servlet/JSP container other than Tomcat. For example, Resin

Scott Ferguson wrote:

 > Actually, the underlying problem is a difficult one. Unfortunately, URLs
 > don't have an official character encoding. It looks like we're drifting
 > toward UTF-8 as a default, but that's not specified in the HTTP
 > specifications.
 > Because the HTTP request does not specify the URL encoding, the web
 > server needs to guess. It's somewhat of an ugly problem.
Today's JSPs have page directive, its contentType and pageEncoding
attributes. A server doesn't need to bring rabbit out of a hat. Simply
put in other words, Tomcat behavior is just substandard negligence.

I have noticed that servlet generated from JSP by Resin has correct
setCharacterEncoding() call even when the original JSP doesn't have
the call. Resin may be called 'superstandard.' :)

 > That somewhat translates into the Servlet/JSP forward/include issue.
 > Resin's approach is to realize that the Java string for the
 > URL/QueryString is 16-bits, so there's no need to do any encoding until
 > there's a sendRedirect or something similar.
 > -- Scott

Dennis Thrysøe wrote:
> Hi,
> I'm having problems including a JSP page from another JSP page using 
> parameters with special characters.
> I looked through the archives, but couldn't find anything about this issue.
> I can encode a string, and the result is correct
>   URLEncoder.encode("blåbærgrød", "ISO-8859-1")
> But if I make an include with the same value
>   <jsp:include page="bar.jsp" flush="true">
>     <jsp:param name="word" value="blåbærgrød" />
>   </jsp:include>
> The special characters are replaced with question marks '?' (%3F). So 
> the query string seen from bar.jsp becomes
>   word=bl%3Fb%3Frgr%3Fd
> In fact the generated java code for the main jsp file contains this 
> string also. So the problem is already during parsing or servlet 
> generation.
> The requests character encoding is null. The page directive's 
> pageEncoding attribute is "ISO-8859-1" (or not present - doesn't make a 
> difference.
> The user properties and user.language are 'US' and 'en' 
> respectively. Might that be the cause?
> The problem is on Tomcat 4.1.29 on Linux.
> By the way: I still haven't figured out whether Tomcat 4.1.30 is 
> supposed to be able to run on JDK 1.3.1.
> Any help appreciated,
> -dennis
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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:
For additional commands, e-mail:

View raw message