You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Raymond <pp...@hotmail.com> on 2004/11/03 10:38:43 UTC

Request Parameters Encoding Problem

Dear Tapestry Users,

For my application I need to retrieve http request parameters composed of
non-Latin-1 characters from the servlet request.
However, I found that the parameters could not be properly decoded even
after I have performed the following:

HttpServletRequest req = getRequestCycle().getRequestContext().getRequest();
req.setCharacterEncoding("UTF-8");            // Servlet API 2.3 method;
doesn't work
String param = req.getParameter("param");    // param contains wrong
characters

The problem can be solved by the clumsy Servlet API 2.2 method:
String param = new
String(req.getParameter("param").getBytes("ISO_8859_1"),"UTF-8");

I suspect it's because Tapestry has already read the request input stream in
advance using either getReader() or getParameter().
So my question is how to make the Servlet API 2.3 method work with Tapestry
(if possible); or could the request parameters be retrieved in the a
specified charset without invoke the clumsy old method:

new String(param.getBytes("ISO_8859_1"),<charset>);

?

Thanks very much for help.
Raymond

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


Re: Request Parameters Encoding Problem

Posted by Marcus Brito <mb...@gmail.com>.
Are you using Tomcat 5.x? This is a known issue with Tomcat (a design
decision, according to Remy Maucherat):

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23929

Up to 4.x versions, Tomcat always used the same encoding as the body
for URI parameters; starting with 5.0, this is not true anymore -- by
default, it will always use ISO-8859-1, regardless of the body
encoding. You can change this setting by tweaking some HTTP connector
properties.

Now your homework: take a look at the following HTTP connector
properties: URIEncoding and useBodyEncodingForURI -- one or the other
should fix your problem. Searching this mailing list archives will
also get your a few other answers.

-- Marcus Brito <mb...@gmail.com>

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