The Container already implements the HttpServletResponse interface; that’s what you get in the doFilter() and service() methods. But to get this compression filter working, we have to make our own custom implementation of the HttpServletResponse interface and pass that to the servlet via the chain.doFilter() call. And that custom implementation has to also include a custom output stream as well, since that’s the goal—to capture the output after the servlet writes to it but before it goes back to the client.
Creating your own custom HttpServletResponse implementation would be a pain. Especially when all you want to implement are just a few of the methods. And since HttpServletResponse is an interface that extends another interface, to implement your own custom response, you’d have to implement everything in both HttpServletResponse and its superinterface, ServletResponse.
But fortunately, someone at Sun did that for you, by creating a support convenience class that implements the HttpServletResponse interface. All of the methods in that class delegate the calls to the underlying real response created by the Container.