users@jersey.java.net

[Jersey] Setting Content-Language Header

From: <charles_overbeck_at_yahoo.com>
Date: Tue, 24 May 2011 17:23:24 +0000 (GMT)

Is there any reason I can't/shouldn't set the HTTP Content-Language
header in a ContainerResponseFilter? I'm just checking if that sounds
like a good idea.

I know you can call Response.ok().language()... in the individual
resource methods, but then in addition to changing every resource
method to do that, I would also have to change all method signatures to
return a Response, e.g., from

@GET
public JAXBElement<InvoiceType> getInvoice()...

to:

@GET
public Response getInvoice()...

I like the first one better, because it's a more obviously
self-documenting. So far, I only return a Response for @POST annotated
methods, where I need to set the HTTP Location header.

So I'm thinking that because I'm going to have the whole service
localized for a certain set of languages, that I could just figure out
in a ContainerReponseFilter what language all resource methods will
return given the Accept-Language header, and set the Content-Language
header accordingly.

Any thoughts? Has anybody else tackled this in a different way?

Thanks,

Charles