users@jersey.java.net

Re: [Jersey] [Client API] How to obtain ETag and LastModified of received entity?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 25 Aug 2008 08:47:15 +0200

On Aug 24, 2008, at 5:03 PM, Markus KARG wrote:

> I am using the Client API and want to know how I can obtain the
> ETag and LastModified of a received entity?
>
> Currently I am doing this:
>
> Client client = Client.create();
> WebResource r = client.resource("http://192.168.0.15:8080/
> JaxRsSample/sample/Test%201%20/%201.article");
> String entity = r.get(String.class);
>
> How to find out the ETag and LastModified of this result?
>

   ClientResponse cr = r.get(ClientResponse.class);
   String entity = cr.getEntity(String.class);
   EntityTag et = cr.getEntityTag();
   Date lm = cr.getLastModified();

Paul.

> Thanks
> Markus
>
> --
> http://www.xing.com/go/invita/58469
>