Add Response Header to JAX-RS Webservice

jconlin picture jconlin · Sep 29, 2009 · Viewed 9k times · Source

I am trying add some response headers to some of my webservice calls. I wrote my webservice using CXF 2.1.2 and JAX-RS. I need to return an object and I also want to add some headers to the Response. Without returning a javax.ws.rs.core.Response object, how do I add a header to the response and still return my javabean?

Answer

Heri picture Heri · Sep 29, 2009

You can inject a reference to the actual HttpServletResponse via the @Context annotation in your webservice and use addHeader() etc. to add your header.