title: servlet chain filter
body: <p>How can I write a filter class to pass the response from one servlet to another along with the GET parameters?  </p>
  
  <p>This is the outline of what I've tried (I got most of it from <a href="https://stackoverflow.com/questions/8974101/legacy-servlet-chaining-using-servlet-aliasing">this question</a>)</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  public class TranslateFilter implements Filter {
  
    private FilterConfig config = null;
  
    public void init(FilterConfig config) throws ServletException {
      this.config = config;
    }
  
    public void destroy() {
      config = null;
    }
  
    public void doFilter(ServletRequest request, ServletResponse response,
                       FilterChain chain) throws IOException, ServletException {
  
      chain.doFilter(request, response);
      ..
  
      RequestDispatcher dispatch = request.getRequestDispatcher("/Translate");
      dispatch.forward(request, response); 
      ..
    }
  }
  </code></pre>
  
  <p>and this in the web.xml</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;process&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/Process
  &lt;/servlet-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;translate&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/Translate
  &lt;/servlet-mapping&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;processChain&lt;/filter-name&gt;
      &lt;servlet-name&gt;process&lt;/servlet-name&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>But it doesn't not work. It's not forwarding to the second servlet. I don't have a debugging environment setup so I can't tell where it's failing but can someone point me in the right direction? </p>