title: WebFilter urlPatterns ignored
body: <p>I have read numerous examples though I seem to have an 'exact' copy of them, so I cannot figure out why my filter will execute when I navigate to <code>/login</code> instead of <code>/restricted/*</code>. 
  I have tried both annotations (as in the example below) and XML to define the WebFilter.</p>
  
  <p><strong>The Webfilter</strong></p>
  
  <pre><code>@WebFilter(filterName = "AuthenticationFilter", servletNames = { "Faces Servlet" }, urlPatterns = { "/restricted/*" } )
  public class AuthenticationFilter implements Filter {
      @Inject
      private SessionManager sessionManager;
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response,
          FilterChain chain) throws IOException, ServletException {
          System.out.println("Active AuthenticationFilter");
          if (sessionManager.getUser() == null) {
              ((HttpServletResponse) response).sendRedirect("/login");
          }
          else {
              chain.doFilter(request, response);
          }
      }
  
      @Override
      public void init(FilterConfig filterConfig) throws ServletException {
      }
  
      @Override
      public void destroy() {
      }
  }
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;servlet&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;   
  &lt;filter&gt;
      &lt;filter-name&gt;Pretty Filter&lt;/filter-name&gt;
      &lt;filter-class&gt;com.ocpsoft.pretty.PrettyFilter&lt;/filter-class&gt;
      &lt;async-supported&gt;true&lt;/async-supported&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt; 
      &lt;filter-name&gt;Pretty Filter&lt;/filter-name&gt; 
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt; 
      &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt; 
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt; 
      &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;
      &lt;dispatcher&gt;ASYNC&lt;/dispatcher&gt;
  &lt;/filter-mapping&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;NoCacheFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;filter.NoCacheFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;NoCacheFilter&lt;/filter-name&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;AuthenticationFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;filter.AuthenticationFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;AuthenticationFilter&lt;/filter-name&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/restricted/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p><strong>Note</strong></p>
  
  <p>Even though the filter is defined in both files, I can assure I am not using both notations at the same time. For the sake of testing and reviewing I however did post them both.</p>
  
  <p>I am new to the use of webfilters, and could not find much about using multiple filters. But what I did read, you can use multiple and they will execute in the order you defined them in <code>web.xml</code>.</p>
  
  <p><strong>Question</strong></p>
  
  <p>Does anyone have a clue as to why my filter will execute on pages as <code>/login</code> too?
  The app is running on Glassfish 3.1.2.</p>