users@jersey.java.net

[Jersey] _at_QueryParam and character encoding

From: Veit Guna <veit.guna_at_gmx.de>
Date: Tue, 25 Oct 2011 10:30:58 +0200

Hi.

I'm using Jersey for my REST API. I encountered problems with query
params while using GET with special characters (german umlauts).
It seems that only UTF-8 encoded query parameters get properly decoded
on the server side. When typing "foo=MyGörmanUmlaut" in Firefox
manually, it converts this visibly (%xy) to iso-8859-1 (AFAIK). Printing
that on the console on server side leads to broken umlauts.
When specifying UTF-8 encoded values (e.g. for ö = %C3%B6), it works.

So my question is, who is responsible for decoding the query parameters
(tomcat, jersey, some locale setting etc.?) and is the current
implementation by design?

If it is in the responsibility of jersey, is it possible to change that
behavior to e.g. iso-8859-1? Or could be something done like reading the
charset to use
from the incoming request (content-type)? So the client can use an
encoding whatever he likes, but must specify it in the request header.
If nothing can be found in
the headers, a configurable default could be used.

Does that make sense?

Thanks
Veit