users@jersey.java.net

[Jersey] Re: _at_QueryParam and character encoding

From: <grave_at_gmx.de>
Date: Tue, 25 Oct 2011 21:29:22 +0000 (GMT)

I dug deeper and found out that this is a common problem.

Per servlet spec, iso-8859-1 is the default encoding for query
parameters.
That is what tomcat uses per default. Newer specs (see
http://en.wikipedia.org/wiki/Percent-encoding, "Current standard")
recommend to use UTF-8 as encoding.

Tomcat allows via configuration to let the content-type of the request
decide what format
the client sends the query parameters in (and mainly the body of
course). That also seems to be true for GET requests (see
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q2).

I was trying to set these config params on my tomcat, but that didn't
work out in combination with jersey. So I took a look at the jersey
code and the query param decoding. It is using UTF-8 hardcoded for
query param decoding. Also it doesn't seem to take the original, tomcat
decoded, params into account. So it's clear why setting the tomcat
config params didn't work out for me.

I injected the HttpServletRequest via @Context to my service and
printed the original query params to the console. And voila, these were
decoded "correctly" as set in the tomcat configuration.

So my question is, is there something planned to allow this behavior
via jersey?
(Let the client specify the encoding of the query params via
content-type header of the request).