You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rohit Seth <ro...@kronos.com> on 2007/12/04 13:22:37 UTC

Supporting accented characters in URL with URIEncoding=UTF-8

I tried to search the issue in forum but couldn't find any solution. We need
to support special characters in URL (like ます or õñü). After going through
various articles we have done following changes to accomplish the same 

1. Added URIEncoding="UTF-8" in connector element.
2. Modified code to set encoding for request and response.

After these changes we are observing following behavior:

1. If url doesn't contain any special character, everything is fine.
2. If url contains a latin character like õñü, value gets corrupted.
3. If url contains a UTF-8 character like ます, values are proper. In this
case even the latin characters are also correct.

I would appreciate any help / insight .

rohit 


-- 
View this message in context: http://www.nabble.com/Supporting-accented-characters-in-URL-with-URIEncoding%3DUTF-8-tf4942812.html#a14149705
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Supporting accented characters in URL with URIEncoding=UTF-8

Posted by Mark Thomas <ma...@apache.org>.
Rohit Seth wrote:
> 1. Added URIEncoding="UTF-8" in connector element.
> 2. Modified code to set encoding for request and response.
> 
> After these changes we are observing following behavior:
> 
> 1. If url doesn't contain any special character, everything is fine.
> 2. If url contains a latin character like õñü, value gets corrupted.
The connector is expecting UTF-8 so if you have characters encoding in
something other than UTF-8 it is going to fail.

> 3. If url contains a UTF-8 character like ます, values are proper. In this
> case even the latin characters are also correct.
> 
> I would appreciate any help / insight .

Try this as a starting point. It should work for any input on a clean
Tomcat install. If you set URIEncoding="UTF-8" on the connector it should
work with GET as well as POST.

<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
   <head>
     <title>Character encoding test page</title>
   </head>
   <body>
     <p>Data posted to this form was:
     <%
       request.setCharacterEncoding("UTF-8");
       out.print(request.getParameter("mydata"));
     %>

     </p>
     <form method="post" action="index.jsp">
       <input type="text" name="mydata">
       <input type="submit" value="Submit" />
       <input type="reset" value="Reset" />
     </form>
   </body>
</html>


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