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 16:29:20 +0200

I found it searching Jersey test code.
You can see this same aproach here http://bit.ly/bMXJhU
<https://jersey.dev.java.net/source/browse/jersey/>

Alexandru Popescu ☀ escribió:
> Thanks I'll try that. But I'm wondering where can I read about this
> approach you are suggesting? I don't remember seeing it anywhere in
> the spec and it doesn't look like using any of the @Context or
> @XParam...
>
> :- alex
>
> 2010/3/30 Jose Javier García Zornoza <josejavier.garcia.zornoza_at_gmail.com>:
>
>> 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
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>