users@jersey.java.net

Re: [Jersey] how to use ApacheHttpClient

From: <reno.rkcrew_at_free.fr>
Date: Tue, 15 Jun 2010 13:45:57 +0200

Thanks Paul,

i found it this info on the web [1] but my problem is where do i put this
configuration ? in each resource or in an "super" resource and the others will
immplement the super class or in a filter class?
If i use a filter class, do i declare it in the web.xml as the following lines:

<init-param>
  <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
  <param-value><mypackage>.MyFilter</param-value>
</init-param>

there no sample for the apache use so that's why i'm a bit lost :-)

S.

[1] :
http://jersey.576304.n2.nabble.com/Session-Handling-not-working-with-Jersey-Client-td4519663.html

> 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
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>