I have five web applications in my project and you want to filter HTTP requests, but I do not want to write a Filter class for each web application, because there will be no application behavior. What is the most practical way to do this?
I tried to create only one Filter in another class library called MyClassLibrary , but it does not work. Other classes in this library can be used by web applications, so I don't think there is a reference problem.
Part of the web.xml filter for one of the applications:
<filter> <filter-name>SampleFilter</filter-name> <filter-class>MyClassLibrary.Filters.SampleFilter</filter-class> </filter> <filter-mapping> <filter-name>SampleFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
This throws an exception:
java.lang.ClassNotFoundException: MyClassLibrary.Filters.SampleFilter
Platform: Windows, NetBeans, GlassFish
source share