We have a situation where we want to use filter for URL’s containing some specific request parameters, e.g:
http://mydomain.com/?id=78&formtype=simple_form&....... http://mydomain.com/?id=788&formtype=special_form&.......
and so on, id are fetched at run time, I want configure filter in web.xml only if formtype=special_form. How should achieve the solution? Can Filter be configured with regex patterns?
As far as I know there is no solution for matching requests to filters by query string directly in
web.xml. So you could register the filter in yourweb.xmlusing init-params to make the filter configurable and set a pattern viavoid init(FilterConfig filterConfig)in yourjavax.servlet.Filterimplementation.The configuration would look like this in your web.xml:
Further readings:
http://java.sun.com/javaee/5/docs/api/javax/servlet/Filter.html