ShallowEtagHeaderFilter does not work under WAS8 app server

风流意气都作罢 提交于 2019-12-04 07:18:45

I solved this issue by overriding ServletResponse.flushBuffer method. Under WAS8 flushBuffer is getting called prematurely. Passing a HttpServletResponseWrapper with a no-operation flushBuffer method to ShallowEtagHeaderFilter did the trick.

public class HttpCacheFilter extends ShallowEtagHeaderFilter {

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

        HttpCacheResponseWrapper responseWrapper = new HttpCacheResponseWrapper(response);
        super.doFilterInternal(request, responseWrapper, filterChain);
    }

    private static class HttpCacheResponseWrapper extends HttpServletResponseWrapper {

        public HttpCacheResponseWrapper(HttpServletResponse response) {
            super(response);
        }

        @Override
        public void flushBuffer() throws IOException {
            // NOOP
        }
    }
}

i think the above problem can be resolved by adding this custom property

com.ibm.ws.webcontainer.invokeFlushAfterService = false

Divya

I was using extremecomponents jar file using

chain.doFilter(request, new ExportResponseWrapper((HttpServletResponse) response))

faced "Cannot set header. Response already committed" in WAS8 .

by

    @Override
    public void flushBuffer() throws IOException {

    }

in ExportResponseWrapper class , saved my life.

Thanks a lot ... :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!