users@jersey.java.net

Re: [Jersey] _at_FormParam, _at_Context HttpContext and _at_Context HttpServletRequest

From: Jose Javier García Zornoza <josejavier.garcia.zornoza_at_gmail.com>
Date: Tue, 30 Mar 2010 13:48:50 +0200

Hello.
Try this:

@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
   public Response mset(MultivaluedMap<String, String> formParams) {
....
   }



Alexandru Popescu ☀ escribió:
> Hi all,
>
> I am not really sure if it is something wrong with the below code or
> just something I don't understand:
>
> @POST
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> public Response mset(@Context HttpContext httpContext,
> @FormParam("nx") String nx) {
> Form form= httpContext.getRequest().getFormParameters();
>
> assertNotEmpty(form); // <== this FAILS, even if I'm 100% form
> data is submitted
> }
>
>
> @POST
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> public Response mset(@Context HttpServletRequest request,
> @FormParam("nx") String nx) {
> Map params= request.getParameterMap();
>
> assertNotEmpty(form); // <== this FAILS, even if I'm 100% form
> data is submitted
> }
>
>
> For both above cases, if I'm using @FormParam-s the form parameters
> are correctly retrieved. The problem I'm trying to solve is that
> my service is not aware beforehand of all form parameters so it needs
> to retrieve all of them.
>
>
> For current code I am using Grizzly 1.9.18 with the following setup:
>
> SelectorThread threadSelector =
> GrizzlyWebContainerFactory.create(BASE_URI, initParams);
>
>
> Any ideas what I'm doing wrong?
>
> Many thanks in advance,
>
> :- alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>