7

When adding / updating a response header after the request has been processed I get the following warning:

com.ibm.ws.webcontainer.srt.SRTServletResponse setHeader SRVE8094W: WARNING: Cannot set header. Response already committed. 

I am trying to manipulate the header by calling httpServletResponse.setHeader() or httpServletResponse.addHeader() from within a servlet filter after filterChain.doFilter() or by postHandle code spring interceptor.

I have encountered this problem while running my webapp using spring 3.x on websphere 8.5.

The problem is not reproduced on tomcat 7.0 therefore my guess is that it is Websphere related. The problem is not reproduced in a pure servlet app therefore my guess is that it is Spring related.

I am familiar with

ShallowEtagHeaderFilter does not work under WAS8 app server

and with

Cannot set header in JSP. Response already committed

but I am looking for a "cleaner" solution.

Can anybody help me on this?

Community
  • 1
  • 1
Oren Ezer
  • 71
  • 1
  • 3

1 Answers1

-1

Websphere strictly follows the J2EE standard, hence whatever works in Tomcat need not necessarily work in Websphere. In my project, I got a lot of exception/errors which are particular for Websphere, but works as a charm in Tomcat. I suggest you to set the header in the controller. One other alternate is not to flush the output stream in the controller (if you have done it explicitly).