users@jersey.java.net

[Jersey] Re: Curl, Jersey and InFormParam multi valued map.

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Tue, 29 Mar 2011 13:24:31 -0700

Hi Rahul,

i do not see anything wrong in the code regarding the form processing.
This should just work. Could you please re-try without the username/password
security thing?

A similar form processing code could be find at the simple-console [1]
jersey example for your reference.

~Jakub

[1]http://download.java.net/maven/2/com/sun/jersey/samples/simple-console/1.6/simple-console-1.6-project.zip


On 03/29/2011 10:23 AM, Rahul Babbar wrote:
> Any comments!!!
>
> Rahul
>
>
> On Mon, Mar 28, 2011 at 11:17 AM, Rahul Babbar
> <rahul.babbar1_at_gmail.com <mailto:rahul.babbar1_at_gmail.com>> wrote:
>
> Hello all,
>
> I have the following piece of code.
>
>
> @POST
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> public Response doAction(MultivaluedMap<String, String>
> inFormParams) {
> String action = inFormParams.getFirst("action");
>
> Response response = null;
> if(StringUtils.isEmpty(action)) {
> throw new UnrecoverableException("Unexpected null or empty action");
> }
> // do something...
> return response;
> }
>
>
> And i post using the following command from Curl
>
> curl --data "action=updateCache"
> http://$USER:$PASSWORD@localhost:8080/<URI>
>
> both inFormParams and action are empty.
>
> What am i doing wrong? How can i get the post parameters in a map?
>
> Thank you.
>
> Rahul
>
>