How about:
====
String queryString = HttpServletRequest.getParameter("query");
queryString = new String(queryString.getBytes("iso-8859-1"), "UTF-8");
====
Its not very graceful so you can even make a 1-line-method for doing this
and have:
====
decodeURIParams(a, b, c) {
return new String((HttpServletRequest.getParameter(a)).getBytes(b), c);
}
String queryString = decodeURIParams("query", URI_ENCODING_CONST,
URI_DECODING_CONST));
====
This is all pseudo-code but I hope you see what I mean.
On 7/26/07, Frederic Bastian <Frederic.Bastian@(protected):
>
> Hi Pulkit, thanks for your answer.
>
> The matter is that Tomcat won't get the correct values of the parameters
> in the URL. For instance :
>
> If my URI looks like : http://host/?query=%C3%A9%C3%A8
> The URI encoding is UTF-8
>
> By default, Tomcat will read this url in ISO-8859-1. So
> HttpServletRequest.getParameter("query") will return an incorrect value.
> The solution you proposed won't help Tomcat to return a correct value
> with the "getParameter" method.
>
> If I add into server.xml the attribut URIEncoding="UTF-8" to the
> Connector, Tomcat will correctly read the "query" parameter.
> I would like Tomcat to read correctly URL in UTF-8, but without
> modifying server.xml.
>
> Any suggestion ?
>
> Pulkit Singhal a écrit :
> > Hi Frederic,
> >
> > I don't know about HttpSession.<method> for settign the URIEncoding.
> > But you could always do somethign along the lines of:
> > String uri_utf8 = new String (uri.getBytes("iso-8859-1"), "UTF-8");
> > inside the application.
> >
> > On 7/26/07, Frederic Bastian <Frederic.Bastian@(protected):
> >>
> >> Hi folks :)
> >>
> >>
> >> I need my URI to be in UTF-8. In server.xml, I added to the Connector
> >> the attribut : URIEncoding="UTF-8"
> >> This works well. But my question is :
> >>
> >> Is there a way to define the URIEncoding in the application itself ?
> >>
> >> For instance, you can modify the session timeout in the application
> >> itself (HttpSession.setMaxInactiveInterval()). I would like to modify
> >> the URIEncoding by the same way.
> >>
> >> Would anyone know how to achieve that ?
> >> Thanks.
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@(protected)
> >> To unsubscribe, e-mail: users-unsubscribe@(protected)
> >> For additional commands, e-mail: users-help@(protected)
> >>
> >>
> >
>
> --
> Frederic Bastian, PhD student
> Department of Ecology and Evolution
> Biophore, University of Lausanne, 1015 Lausanne, Switzerland.
> tel: +41 21 692 4221
> http://www.unil.ch/dee/page22707.html
>
> Swiss Institute of Bioinformatics
> http://www.isb-sib.ch/
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
>
>