The answer is already made when using Spring 3.x on Websphere 8.5

When adding / updating the response header after processing the request, 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 the servlet filter after filterChain.doFilter() or postHandle code spring interceptor.

I ran into this problem when running my webapp using spring 3.x on webpage 8.5.

The problem does not reproduce on tomcat 7.0, so I assume it is related to Websphere. The problem does not reproduce in a pure servlet application, so I assume that it is related to spring.

I am familiar with

ShallowEtagHeaderFilter does not work under WAS8 application server

and

Unable to set header in JSP. The answer is already made

but I'm looking for a β€œcleaner” solution.

Can someone help me with this?

+6
source share
1 answer

Websphere strictly follows the J2EE standard, so anything that works on Tomcat does not have to work on Websphere. In my project, I got a lot of exceptions / errors that are typical for Websphere, but it works like a charm in Tomcat. I suggest you set the header in the controller. Another alternative is not to clear the output stream in the controller (if you have done this explicitly).

-1
source

Source: https://habr.com/ru/post/951754/


All Articles