1

I'm writing a fairly generic webapp that I want to be JAX-RS "pure", though I'm developing using Jetty and CXF. I want to do something extremely simple, I want for ALL HTTP responses a header added (not just for the methods I'm writing code for, even auto-handled 415 responses).

Solutions for How do i modify HTTP headers for a JAX-WS response in CXF? seem overly complex (and specific for CXF's implementations of JAX-RS)for just needing to add: MyServerVersion : 1.0 to every response.

Community
  • 1
  • 1
SteveS
  • 407
  • 2
  • 11

2 Answers2

1

The standard way to do this is with a ContainerResponseFilter. See Chapter 6: Filters and Interceptors of the JAX-RS specification.

You'll want to add your header to ContainerResponseContext#getHeaders(). See this question for an example.

Community
  • 1
  • 1
DannyMo
  • 11,344
  • 4
  • 31
  • 37
0

Thanks for answer above, I summarized what I did in a blog post and it gives some background and context for the Accept-Post response header I was working with and code samples.

SteveS
  • 407
  • 2
  • 11