I need to modify this header based on page contents.
eg: this is a contrieved example-since it was requested. I cannot go into the details of the specific header
The servlet/page sets a header specialheader=xyz based on what backend system was accessed. If this specialheader is set the filter will modify it to xyz+abc. If the header is not set, the filter will set it to 123.
I could use a filter to create a wrapped HttpServletResponse and modify it on its way back. However, I am fuzzy on the details.
I know I have to prevent the output from being sent back to client before my filter does its job. In order to do this, do I need to pass it my own OutputStream and buffer the output?
Do I really need to do that ? can I avoid buffering the output which may put load on the server
The basic question is- if I need to modify the header AFTER the doFilter call, what is the minimum do I need to do ?
Is there some other way of preventing the output from being committed such as overriuciding flush etc., ?
Just implement getHeader and getHeaderNames to ignore the header you want to discard and set the Wrapper as a filter.