How can I write a filter class to pass the response from one servlet to another along with the GET parameters?
This is the outline of what I've tried (I got most of it from this question)
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);
..
}
}
and this in the web.xml
<servlet-mapping>
<servlet-name>process</servlet-name>
<url-pattern>/Process
</servlet-mapping>
<servlet-mapping>
<servlet-name>translate</servlet-name>
<url-pattern>/Translate
</servlet-mapping>
<filter-mapping>
<filter-name>processChain</filter-name>
<servlet-name>process</servlet-name>
</filter-mapping>
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?