users@jersey.java.net

Re: [Jersey] Re: Form parameters + glassfish 3.1

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Mon, 30 Aug 2010 11:44:33 +0200

Hi John,

This behavior is triggered for:

1) POST request with the media type "application/x-www-form-
urlencoded" and there are no bytes to read from the request input
stream; and

2) there are parameters present, HttpServletRequest.getParameterNames
returns a non-empty enumeration.

Would it be possible to log the request being received from the server
to check what the client is sending?

It may be you might be able to reproduce the same behavior using just
a raw servlet. If the request input stream is empty and you know it
should be there is definitely a regression in the Web container.

In the meantime i will check the latest GF nightly to see if there is
a regression in the Web container.


There are two possible work around:

1) Include one @FormParam and Form as the method parameters;

2) Define a bean, X say, containing the @FormParam annotations and
inject the bean doing @InjectParam X as a method parameter.

Paul.


On Aug 30, 2010, at 8:01 AM, John Lister wrote:

>
> 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>