dev@jsr311.java.net

Re: JSR311: POSTed form data

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 15 Feb 2008 11:45:53 +0100

Hi Marc,

So far the @*Param concept has been associated with the HTTP meta-data
and not that of the entity so it might create some confusion (like you
highlighted when overloading @QueryParam for form parameters).

What happens if the developer specified the following:

   @POST @ConsumeMime("application/x-www-form-urlencoded")
   public Foo update(@QueryParam("name") String name, String formData)

?


My ideal preference would be for a way to unify the processing of the
media types "application/x-www-form-urlencoded" and
"multipart/form-data" [1] using a Java bean that is the entity, for example:

   // The Form interface is a marker for message body readers/writers
   public MyForm implements Form {
      public String name;

      public InputStream uploadedFile.
   }

and allow for:

   @POST @ConsumeMime({"application/x-www-form-urlencoded",
                       "multipart/form-data"})
   public Foo update(MyForm form)


 From this we could consider what it means to specify unwrapped form
parameters in a way that does not clash with the concept of the entity
parameter already specified.

The downside of this approach is that it requires a lot more work to
specify. But interestingly for multipart content we can re-use the
message body readers/writers as we do today for entities.

Paul.

[1] http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4

Marc Hadley wrote:
> Issue 30[1] requests that we improve support for POSTed form data,
> either by supporting it with the existing @QueryParam annotation or by
> adding a new annotation, e.g. @PostParam or @FormParam.
>
> Note that we already require support for
>
> @POST @ConsumeMime("application/x-www-form-urlencoded")
> public Foo update(MultivaluedMap<String,String> formData) {
> String name = formData.get("name");
> ...
> }
>
> where formData can be used to get at the individial form fields.
>
> The suggested addition would add support for doing something like:
>
> @POST @ConsumeMime("application/x-www-form-urlencoded")
> public Foo update(@QueryParam("name") String name) {...}
>
> Opinions ?
>
> If you are in favor, do you think this warrants a new annotations or a
> change to the existing @QueryParam.
>
> If you favor a change to @QueryParam then which should take precedence
> if the same name is used for a field in the request entity and a URI
> query param ?
>
> Thanks,
> Marc.
>
> [1] https://jsr311.dev.java.net/issues/show_bug.cgi?id=30
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109