title: How to add filters to servlet without modifying web.xml
body: <p>I'd like the ability to modify/configure filters in a different way than web.xml. Here is a static configuration of 2 filters. I'd like the ability to have one filter statically configured and allow that filter to load additional filters. I just wanted to know if anyone knows of lib that already has this.</p>
  
  <p>Using Servlet API 2.5</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;web-app&gt;
    ...
    &lt;filter&gt;
      &lt;filter-name&gt;MyFilter1&lt;/filter-name&gt;
      &lt;filter-class&gt;com.me.MyFilter1&lt;/filter-class&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;MyFilter1&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
    ...
    &lt;filter&gt;
      &lt;filter-name&gt;MyFilter2&lt;/filter-name&gt;
      &lt;filter-class&gt;com.me.MyFilter2&lt;/filter-class&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;MyFilter2&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
    ...
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I've seen this done in Guice with GuiceFilter where the Filters are configured at runtime.</p>