Stack Exchange
Can we confgure filters only for a subset of servlets
I have various different categories of servlets. Can I configure the filters in my web.xml such that each filter only applies for one of the categories of servlet.

You can map them on <servlet-name> instead of <url-pattern>.
<filter-mapping>
    <filter-name>yourFilterName</filter-name>
    <servlet-name>yourServlet1Name</servlet-name>
    <servlet-name>yourServlet2Name</servlet-name>
    <servlet-name>yourServlet3Name</servlet-name>
</filter-mapping>

The <servlet-name> must exactly match the same value as in <servlet> definition. This way the filter will be invoked whenever either of those servlets are to be invoked.
