Is there a way to disable a embedded Servlet Filter?
My project has a dependency jar that contains (inside the jar) a @WebFilter
mapped to "/*"
.
I need the jar (it has a lot of commons class of my company), but this new project does not need this WebFilter, actually this new project will not work because this Filter checks user authentication and the new project has no "loggedUser". It's like a website
Thanks
web.xml
takes precedence over annotations for precisely this reason. Simply declare the offending filter in web.xml
the good old way and set its <filter-mapping>
to something bogus, eg:
<filter>
<filter-name>BadBadFilter</filter-name>
<filter-class>com.example.BadBadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>BadBadFilter</filter-name>
<url-pattern>/this-path-does-not-exist/*</url-pattern>
</filter-mapping>
This will effectively disable it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With