users@jersey.java.net

Re: [Jersey] setting cache header on GET method returning a JAXB bean

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 03 Sep 2009 09:49:07 +0200

On Sep 2, 2009, at 9:33 PM, Marc Hadley wrote:

> Change the method return type to Response and use ResponseBuilder to
> build the response. E.g.
>
> @GET
> Response someMethod() {
> SomeJaxbClass obj = ...
> CacheControl cc = new CacheControl();
> cc.setNoCache(true); // etc
> return Response.ok(obj).cacheControl(cc).build();
> }
>

If you want to avoid changing the return type of a resource method it
is also possible to support a filter [1] that analyses the response
data and adds a cache control header.

For example, this could be triggered by your own defined annotation on
the resource method, if you utilize a resource filter. Or it could be
based on the Content-Type, or the entity type, when using a container
response filter.

Please log an issue if you would like such a feature to be supported
by Jersey.

Paul.

[1] https://jersey.dev.java.net/nonav/apidocs/1.1.2-ea/jersey/com/sun/jersey/api/container/filter/package-summary.html

> On Sep 2, 2009, at 3:22 PM, Moiz Dohadwala wrote:
>
>> Hi,
>>
>> How does one set cache (and other ) response headers from a @GET
>> method that is returning a JAXB object?
>>
>> Thanks,
>>
>> -Moiz
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>