users@jersey.java.net

Re: [Jersey] how to use ApacheHttpClient

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 15 Jun 2010 13:21:05 +0200

Some more info...

To enable cooke support:

  ApacheHttpClientConfig cc = new DefaultApacheHttpClientConfig();
  cc.setProperty(ApacheHttpClientConfig.PROPERTY_HANDLE_COOKIES, true);
  Client c = ApacheHttpClient.create(cc);

It add a filter do:

   MyFilter f = ...
   c.addFilter(f);
   https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/filter/Filterable.html
#addFilter%28com.sun.jersey.api.client.filter.ClientFilter%29

Paul.

On Jun 15, 2010, at 1:10 PM, Pavel Bucek wrote:

> Hello,
>
> On 6/15/10 12:28 PM, reno.rkcrew_at_free.fr wrote:
>>
>> hello all,
>>
>> I would like to know how to use the ApacheHttpClientXXX classes. I
>> read the
>> package summary [1] but i don't know how to use it with in a jersey
>> webapp :-(
>>
> you have to create client instance this way:
>
> Client c = ApacheHttpClient.create();
>
> and you need to declare dependency for that:
>
> <dependency>
> <groupId>com.sun.jersey.contribs</groupId>
> <artifactId>jersey-apache-client</artifactId>
> <version>${project.version}</version>
> </dependency>
>
> Hope it helps,
> Pavel
>
>> In the user guide [2], there is this paragraph:
>> "The support for HTTP authentication and cookies is much better
>> with the Apache
>> HTTP client than with HttpURLConnection. See the Java documentation
>> for the
>> package com.sun.jersey.client.apache, ApacheHttpClientState and
>> ApacheHttpClientConfig for more details. "
>> it does not help me a lot :-(
>>
>> My goal is to add a filter for all the requests (that comes from an
>> apache httpd
>> server): if the cookie does not exist, we create it in the filter.
>>
>> Is anybody has ever done it?
>>
>> Regards
>>
>> S.
>>
>> [1] :
>> https://jersey.dev.java.net/nonav/apidocs/latest/contribs/jersey-apache-client/com/sun/jersey/client/apache/package-summary.html
>> [2] :
>> https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html
>> #d4e687
>>
>> ---------------------------------------------------------------------
>> 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
>