Modify the filter chain - Or select servlet to respond to request using filter

Posted by klonq on Stack Overflow See other posts from Stack Overflow or by klonq
Published on 2010-06-11T01:30:28Z Indexed on 2010/06/11 1:32 UTC
Read the original article Hit count: 622

Filed under:
|

I am trying to use a filter to map requests. I am trying to do this for two reasons, firstly to dynamically generate URI's and have them mapped to the appropriate servlet and secondly to catch URI's which are not registered and handle them appropriately.

So I'm using a catch-all filter to process the URI and determine the response. I would like some way of modifying the filter chain, or some way to set the servlet which responds to the request from within the filter. I have been unsuccessful using filterConfig.getServletContext().getRequestDispatcher().forward() to send to jsp, ideally though I would like to map to a servlet but can't figure out how.

The reason I am not doing this from within a servlet is that I have some URIs which are fixed within web.xml and if I use a catch-all servlet those URIs do not get mapped. Is this possible, is it clean or it going to get really messy?

© Stack Overflow or respective owner

Related posts about java

Related posts about filter