title: Need help with creating custom HttpServletResponse
body: <p>Suddenly stuck on generating custom servlet response. I want to replace servlet response with predefined one:</p>
  
  <pre><code>public class MyCustomResponse extends HttpServletResponseWrapper {
    private String customOutput;
    public MyCustomResponse(String customOutput, HttpServletResponse response) {
      super(response);
      // PrintWriter and Outputstream should stream this variable as output
      this.customOutput = customOutput;
    }
  
    //
    // Below I need to override something
    //
  }
  </code></pre>
  
  <p>and filter code snipped as follows:</p>
  
  <pre><code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    //
    //
    MyCustomResponse customResponse = new MyCustomResponse("Hello world!", (HttpServletResponse) response);
    chain.doFilter(request, customResponse);
  }
  </code></pre>
  
  <p>Shame on me, but i'm really stuck on coding this simple task :( </p>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>All I want is to implement custom response wrapper which, once it's put into filter chain, would always respond with some predefined text. I know how to write custom data from within doFilter() method, but I want <code>MyCustomResponse</code> to be responsible for that - just instantiate and put in chain. Any well-reasoned responses "You cant do that because..." are also welcome.</p>