users@jersey.java.net

[Jersey] Re: Cookie handling in jersey client 2.x

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 7 Nov 2014 18:10:32 +0100

What you need is to configure Jersey client to use AHC connector first. See e.g. here:
https://github.com/jersey/jersey/blob/master/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CookieTest.java#L121 <https://github.com/jersey/jersey/blob/master/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CookieTest.java#L121>

Cheers,
Marek

> On 05 Nov 2014, at 10:59, Sapna Bhargava <sapnabhargava.sb_at_gmail.com> wrote:
>
> Hi All,
>
> I have moved from jersey 1.0 to 2.0. In jersey 1.0 Client I was using the following snippet to handle session cookies :
> ApacheHttpClientConfig config = new DefaultApacheHttpClientConfig();
> config.getProperties().put(ApacheHttpClientConfig.PROPERTY_HANDLE_COOKIES, true);
>
> Is there any mechanism to do the same in jersey client 2? I tried the below but it doesnt persist the cookies:
> ClientConfig clientConfig = new ClientConfig();
> clientConfig.property(ApacheClientProperties.DISABLE_COOKIES, false);
>
> Do we need to create a RequestFilter to do the same?
>
> Thanks in advance,
> Sapna
>
>
>
>