I try to implement a HttpServletResponseWrapper in order to read the content of a servlet response. I can successfully read to content in the filter. But the final packet which go out of the application has an empty body (check with browser and fiddler)

### Implementation

```
class ReadableContentHttpServletResponse extends HttpServletResponseWrapper {
    private ByteArrayOutputStream outputStream;
    private ServletOutputStream servletOutputStream;

    public ReadableContentHttpServletResponse(HttpServletResponse response) {
        super(response);
        outputStream = new ByteArrayOutputStream();
        servletOutputStream = new ServletOutputStream() {
            private WriteListener writeListener = null;

            @Override
            public void write(int b) throws IOException {               
                outputStream.write(b);
                if (writeListener != null) {
                    writeListener.notify();
                }
            }

            @Override
            public void setWriteListener(WriteListener writeListener) {
                this.writeListener =  writeListener;

            }

            @Override
            public boolean isReady() {
                //ByteArrayOutputStream.close() has not effect 
                return true;
            }
        };
    }

    @Override
    public PrintWriter getWriter() throws IOException {
        return new PrintWriter(outputStream);
    }

    @Override
    public ServletOutputStream getOutputStream() throws IOException {
        return servletOutputStream;     
    };

    //... Getters...    
}

```

### The filter

```
...
ReadableContentHttpServletResponse wrappedResponse = new ReadableContentHttpServletResponse(httpResponse);
chain.doFilter(request,wrappedResponse);
log.debug("content = " + wrappedResponse.getContent()); //working
log.debug("content = " + wrappedResponse.getContent()); //working

```

I tried to read several time the `ByteArrayOutputStream` in the filter (which works) or not, but the final body's packet is still empty. I also tried with the `ByteArrayOutputStream` of apache.

Note that there is only one filter, and I removed everything that was coming after the `dofilter`.

EDIT: The stream used to generate the final packet is not the `ServletOutputStream` of the wrapper. It is the `ServletOutputStream` of the original `HttpServletResponse response`.

**Why?** Sincethe wrapper overloads the `ServletResponse`methods and is given to `dofilter(..)`, it should use the stream returned by the wrapper.