I'll preface this with the fact that I'm still using version 0.4, so if
a good answer is "already fixed in a newer version", then awesome.
I'm running into problems using POST with my resources. I just want to
get at application/x-www-form-urlencoded name/value pairs. If I pass a
FormURLEncodedProperties parameter to my resource method, that seems to
work, until I introduce a filter or a Tomcat valve (e.g. request dumper)
somewhere in the processing chain before it, that reads from the input
stream. Jersey doesn't seem to reset the stream (not sure if that's
even possible), and so I end up with an empty FormURLEncodedProperties.
Another approach that I've tried is adding a
@Resource private HttpServletRequest _request;
field to my resource, and then just reading the request parameters
directly from that inside my resource method. That one's a bit more
interesting, as it seems to work exactly backwards of the other
approach. :) Jersey looks to be wrapping the servlet request and
causing some problems. If I don't touch the servlet request before it
gets to Jersey, I get an empty set of parameters from the request.
Then, to try to debug it, I added this line:
System.out.println("------------JERSEY SERVLET: " +
req.getParameterMap());
to the beginning of the Jersey servlet's service() method, and after
that I was always able to get my parameters from the request.
I didn't dig too deeply into the code, but the overall problem seems to
be around the way that Jersey wants to read the parameters directly from
the servlet input stream, instead of reading them from the actual
servlet request. It's making too many assumptions about the
environment.
Is there a good recommended, reliable way to read posted,
form-urlencoded parameters in a Jersey resource?
Thanks.
--Tim