Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you package a WebFilter into a library

And if so how do you do it?.

Yes sounds like my last question. And it is essentially the same problem. I have a @javax.servlet.annotation.WebFilter which works fine when packaged directly into a war. Now I would like to move the filter in to a library. But if I do so it won't be called any more.

Any pitfalls I have to look out for or is it just plain impossible?

like image 246
Martin Avatar asked Sep 07 '25 11:09

Martin


1 Answers

Set <web-app metadata-complete="false">.

This means that the metadata for this web application is not limited to this particular xml (and the classes of the webapp), but can use metadata by 3rd party libraries.

Also take a look at "web fragments". You can define a web-fragment.xml in META-INF of your jar, and map all servlets and filters there.

Take a look at this demo.

like image 171
Bozho Avatar answered Sep 10 '25 21:09

Bozho