users@jersey.java.net

Re: [Jersey] MultivaluedMap

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 28 Oct 2009 18:46:53 +0100

On Oct 28, 2009, at 6:35 PM, Ronak Patel wrote:

> Paul,
>
> Can you paste me the exact code you use to add variables to the map?
>

> Is it the same as what I'm doing below?
>

Yes, I copied and pasted it.

I do not have time right now, but if i have time tomorrow i will
create a simple maven project that you can test with.

Paul.

>
> Ronak
>
> From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> To: users_at_jersey.dev.java.net
> Sent: Wed, October 28, 2009 7:48:53 AM
> Subject: Re: [Jersey] MultivaluedMap
>
> Hi,
>
> I tested with 1.0.3.1 and i cannot reproduce.
>
> All i can suggest is you send me a simple maven project that
> reproduces the issue.
>
> Paul.
>
> On Oct 28, 2009, at 2:42 PM, Ronak Patel wrote:
>
>> Paul,
>>
>> I'm using Jersey version 1.0.3.1.
>>
>> I tried doing put and add with the same result. I even tried to
>> loop through the String array on my own and add one at a time.
>>
>> Ronak
>>
>> From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
>> To: users_at_jersey.dev.java.net
>> Sent: Tue, October 27, 2009 11:44:47 PM
>> Subject: Re: [Jersey] MultivaluedMap
>>
>> Hi Ronak,
>>
>> What version of Jersey are you using?
>>
>> I tried a quick test with 1.1.4-ea-SNAPSHOT and it worked as you
>> expect. There is no code to explicitly write "," in the URI builder
>> implementation.
>>
>> BTW you can also do the following which is equivalent:
>>
>> resource.queryParam("id", "hello").queryParam("id",
>> "there").get(ClientResponse.class);
>>
>> Are you sure you did not do:
>>
>> queryParams.add("id", Arrays.asList(new String[]{"hello",
>> "there"}));
>>
>> ?
>>
>> which will create query string:
>>
>> ?id=%5Bhello,+there%5D
>>
>> Paul.
>>
>> On Oct 28, 2009, at 3:36 AM, Ronak Patel wrote:
>>
>>> Paul,
>>>
>>> I have a quite a basic question which I am embarrassed to ask but
>>> one I've been scratching my head about...
>>>
>>> I'm using MultivaluedMap and MultivaluedMapImpl to set my
>>> queryParams on the JAX-RS Jersey Client API
>>>
>>> and I don't see Jersey formulate my expected url.
>>>
>>> I am doing as so:
>>>
>>> Client client = Client.create();
>>> WebResource resource = client.resource("http://somehost.com/
>>> someuri");
>>> MultivaluedMap<String, String> queryParams = new
>>> MultivaluedMapImpl();
>>>
>>> queryParams.put("id", Arrays.asList(new String[]{"hello",
>>> "there"}));
>>>
>>> resource.queryParams(queryParams).get(ClientResponse.class);
>>>
>>> Now, I don't see Jersey formulate the list of parameters as
>>> id=hello&id=there...and instead I see id=hello,there which is not
>>> what I want.
>>>
>>> What should I be doing to obtain a url with id=hello&id=there?
>>>
>>> Thanks,
>>>
>>> Ronak
>>>
>>>
>>
>>
>>
>
>
>