I'm adding the headers in my complete method below and I think as you have
mentioned that Response.ok should work, using the injected HttContext should
work as well. Btw, this used to work with HttpServletRequest injection (i.e
HttpServletRequest.setHeader("Content-Location", uri.toString());)
Thanks.
@GET
@Produces({"application/xml;charset=UTF-8",
"application/json;charset=UTF-8", "application/javascript"})
public HelloWorld sayHello() {
return complete(new HelloWorld());
}
@GET
@Produces({"application/xml;charset=UTF-8",
"application/json;charset=UTF-8", "application/javascript"})
public HelloWorld sayHello() {
return Response.ok().entity(entity).header("myHeader", "value").build();
}
@Context private HttpContext _context;
protected <ElementType extends RootYahooElement> ElementType
complete(ElementType element)
{
if(_context.getResponse() != null) {
_context.getResponse().getHttpHeaders().putSingle("Content-Location",
uri.toString());
_context.getResponse().getHttpHeaders().putSingle("Content-Language",
element.getLang());
}
return element;
}
--
View this message in context: http://jersey.576304.n2.nabble.com/Response-headers-gets-removed-using-HttpContext-tp6650678p6657069.html
Sent from the Jersey mailing list archive at Nabble.com.