I'm really confused about the WebFilter annotation with Dynamic Web Modules >= 3.0. I read this article ( https://www.concretepage.com/java-ee/jsp-servlet/how-to-use-filter-in-servlet-3-with-webfilter-annotation ) telling that @WebFilter cannot be used without web.xml because @WebFilter does not define order, it only reduces the configuration stored in web.xml.
I was not able to create a web.xml without the url patterns. E.g. this is invalid:
<filter-mapping>
<filter-name>OAuthSecurityFilter</filter-name>
</filter-mapping>
<filter-mapping>
<filter-name>GuiceFilter</filter-name>
</filter-mapping>
It is invalid because in addition to filter-name, one has to provide at least a server name or an url mapping. But in that case, I wonder what it means if I also specify the value to the annotation:
@WebFilter(value="/*", filterName="OAuthSecurityFilter")
public class OAuthSecurityFilter implements Filter {
You see, if you cannot specify the filter without the url pattern in web.xml, and if you must provide the filter in web.xml, then what is the point in having the "value" in the WebFilter annotation? Will it be ignored? Will it override the url-pattern given in web.xml?