Results 1 to 2 of 2

Thread: Adding Headers in interceptor's postHandle

  1. #1
    Join Date
    Aug 2005
    Location
    Colorado
    Posts
    8

    Default 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()?

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

  2. #2
    Join Date
    Aug 2005
    Location
    Colorado
    Posts
    8

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •