My company has a servlet filter we would like to include in various 3rd party Java web applications. There is some hesitancy to edit the vendor’s web.xml file. Is this hesitancy warranted? Is there another way to do this? The app servers in question are Tomcat and Weblogix…
Share
If using Servlet API up to version 2.5 – there is no other way if you want portability – you must include the
Filterin web.xml.If using Servlet API 3.0, you can use
web-fragment.xmlinside your jar, or@WebFilterannotation on the filter, and it will automatically be deployed (the web-app should only specifymetadata-complete="false"in order to include declarations from other modules)