tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Funk <a...@alexfunk.de>
Subject Re: How to control encoding of response.sendRedirect? (Tomcat 5.5.17)
Date Sun, 23 Sep 2007 12:14:33 GMT
Thanks to all that responded, that helped me a lot to make sense from it 
all.

 >> On 22/09/2007, at 10:27 AM, Mark Thomas wrote:
 >>> Check the HTTP spec. I am pretty sure (but haven't checked) that the
 >>> headers must always be in ISO-8859-1.
Yes, the RFC2616 says:
> message-header = field-name ":" [ field-value ]
> field-name = token
> field-value = *( field-content | LWS )
> field-content = <the OCTETs making up the field-value and consisting of 
 > either *TEXT or combinations of token, separators, and quoted-string>
[...]
> Words of *TEXT MAY contain characters from character sets other than 
 > ISO-8859-1 [22] only  when encoded according to the rules of RFC 2047

I assumed that where ever a Java-String was converted into bytes there 
would be some place to specify the encoding. Here in sendRedirect the 
encoding is implicitly ISO-8859-1. I passed sendRedirect a String with 
characters outside ISO-8859-1 out of curiosity and it gives no error but 
the 'Location'-header contains something other then 
String#getBytes("ISO-8859-1") would give. Anyway you should not do that...
 > From: "Adrian Sutton" <adrian@symphonious.net>
 >> This is correct, however you can URL encode the URL with UTF-8 to get
 >> unicode characters to pass through safely. Most modern user agents
 >> handle UTF-8 encoded URLs correctly.

...and always encode the URL before calling sendRedirect.
In case of sendRedirect aka the 'Location'-header I hope that the 
browsers will just pass the URL unchanged, at least if the encoded URL 
is in the ASCII-Range?!

Martin Gainty wrote:
> good point
 > 
http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/index-011206.html

Thanks again, a very valuable link for my issue. I already had bad 
feelings about the URIEncoding in the connector, since it was not 
container independent.

I will try to implement that suggestion. I use Struts2 so I will have to 
do this somewhere in an interceptor or look for something that is 
already there for the problem.

I wonder if this only applies to URL-parameters, like the name 
PARAMETER_ENCODING suggests or also on the path of the URL that may 
contain the UTF-8 characters in my case.

Best regards,

Alex


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message