users@jersey.java.net

[Jersey] Re: get all form parameters programmatic

From: Miroslav Fuksa <miroslav.fuksa_at_oracle.com>
Date: Tue, 07 May 2013 16:11:04 +0200

Hi Ravi,

in Jersey 1 you can use

com.sun.jersey.api.representation.Form

in the similar way.

Jersey 2 has not yet been finally released but you can use latest not
final release to play with. How difficult the migration is depends on
how much of Jersey 1 API you use (depends a lot on your particular project).

Mira


On 6.5.2013 19:57, Hingarajiya,Ravi wrote:
> Hi Mira,
>
> Thanks for the prompt response.
>
> I am using Jersey 1.8.1 library. It is difficult to move from 1.8.1 to
> 2.0.
> Is there any option in Jersey 1.8.1 ?
>
> Thanks,
> Ravi
>
>
>
> On Mon, May 6, 2013 at 4:43 AM, miroslav fuksa
> <miroslav.fuksa_at_oracle.com <mailto:miroslav.fuksa_at_oracle.com>> wrote:
>
> Hi,
>
> If you speak about Jersey2/JAX-RS 2.0, you can use
> "javax.ws.rs.core.Form" and define it as an entity.
>
> For example:
> @POST
> public String post(Form form) {
> ...
> }
>
> Form is an entity parameter. You can then call "form.asMap()" to
> get map or form params.
>
> Mira
>
>
>
>
>
> On 6.5.2013 4:34, Hingarajiya,Ravi wrote:
>> I am looking Is there any way to get all form parameters
>> programmatic way instead of @FormParam annotation.
>> I may not know all Form Parameter key during developing JAXRS
>> REST Service. We can't use @FormParam in this situation APIk.
>> I can retrieve all query parameters using @Context. I am looking
>> similar way to get all form parameters.
>>
>> @POST
>> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
>> @Produces(MediaType.APPLICATION_JSON)
>> public String post(@Context UriInfo uriinfo) {
>> *MultivaluedMap<String, String> params =
>> uriinfo.getQueryParameters();*
>>
>> }
>>
>>
>> Thanks,
>> Ravi Hingarajiya
>
>