Webfilter double urlpattern definiton required?

269 Views Asked by At

I am using Tomcat 7 in my JSF-Project and I am working with Webfilters

I have following problem: When I define a Webfilter like below, Tomcat starts without problems:

@WebFilter(filterName="isLoggedInFilter", urlPatterns={"/pages/*"})
public class IsLoggedInFilter implements Filter {...}

web.xml:

<filter-mapping>
    <filter-name>isLoggedInFilter</filter-name>
    <url-pattern>/pages/*</url-pattern>
</filter-mapping>

But when i leave the url-pattern in the web-xml empty (because I don't want to specify the url-pattern twice the same, tomcat fails to start and gives me following exception: java.lang.IllegalArgumentException: Invalid in filter mapping

<filter-mapping>
    <filter-name>isLoggedInFilter</filter-name>
    <url-pattern />
</filter-mapping>

Do I really have to define the url pattern twice?? If i don't specify it in the Webfilter Annotation, it tells me to specify either or

Any suggestions?

0

There are 0 best solutions below