users@jersey.java.net

Re: Form parameters + glassfish 3.1

From: John Lister <john.lister_at_kickstone.com>
Date: Mon, 30 Aug 2010 07:01:31 +0100

Hi, I've just started testing Glassfish 3.1 dev code while currently
using 3.0.1 and come across a situation that I could do with some advice
on, I'm currently using Jersey 1.4.0.
For some of my post requests I've got methods along these lines:

public Response postXXX(Form formData){
...
}

where the request accept a large number of variable parameters which are
then checked within the code depending upon their contents which seems
much preferable to many FormParam tagged parameters. However using
Glassfish 3.1 I now get the following warning:

WARNING: A servlet POST request, to the URI http://localhost:8080/xxx/,
contains form parameters in the request body but the request body has
been consumed by the servlet or a servlet filter accessing the request
parameters. Only resource methods using @FormParam will work as
expected. Resource methods consuming the request body by other means
will not work as expected.

and indeed my formData parameter is now null, whereas those tagged with
FormParam are filled. However previous versions of Glassfish behave
differently and fill the map.
As far as I can tell nothing else has changed, there are no extra
(default) servlets or filters installed and the only other servlet is
the jersey one. Is this expected and is it possible to revert to the
previous behaviour or are the other methods of accessing the map of form
params in a request? Using HttpRequestContext.getFormParameters() also
returns an empty map.

How come @FormParam can access the data, but a Form object cannot - I'm
guessing that it is extracted to generate the @FormParam objects..

Thanks


John