Announcement Announcement Module
No announcement yet.
Adding Headers in interceptor's postHandle Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding Headers in interceptor's postHandle

    In my postHandle() method of my interceptor, I need to add an HTTP Header to the response (or possibly override it if it exists).

    I've tried response.setHeader("someheader", "somevalue") as well as response.addHeader("someheader", "somevalue"), but neither actually adds the header to the response.

    Can this be done in postHandle()?

    Last edited by dbreese; Oct 29th, 2008, 08:49 AM.

  • #2
    Well, I figured it out...Kinda...

    Turns out, same issue with Jetty and Tomcat (figured MAYBE it was a container issue). So...

    Debugged to ensure that the response object contained the correct header value up until Spring returned back to the container. Result: The HttpServletResponse instance still had the correct header value.

    I found in my code I was invoking response.setContentLength() BEFORE I was doing anything with the headers. If I comment it out, everything works fine.

    So, the remaining mystery is, why does calling response.setContentLength() lock things down and not allow any headers to be modified? I didn't think the content body had anything to do with the other headers.