title: How do a web filter in JSF 2?
body: <p>I create this filter :</p>
  
  <pre><code>public class LoginFilter implements Filter {
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  
          HttpServletRequest req = (HttpServletRequest) request;
          HttpSession session = req.getSession();
  
          if (session.getAttribute("authenticated") != null || req.getRequestURI().endsWith("login.xhtml")) {
              chain.doFilter(request, response);
          } else {
              HttpServletResponse res = (HttpServletResponse) response;
              res.sendRedirect("login.xhtml");
              return;
          }
  
      }
  
      @Override
      public void init(FilterConfig filterConfig) throws ServletException {
  
      }
  
      @Override
      public void destroy() {
      }
  }
  </code></pre>
  
  <p>This is my structure:</p>
  
  <p><img src="https://i.stack.imgur.com/L8dgd.jpg" alt="enter image description here"></p>
  
  <p>And then I add the filter in the web.xml:</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;LoginFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;filter.LoginFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;LoginFilter&lt;/filter-name&gt;
      &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>The filter works as it should but keeps giving me this error:</p>
  
  <pre><code>"Was not possible find or provider the resource, login"
  </code></pre>
  
  <p>And after that my richfaces doesn't works anymore. </p>
  
  <p>How can I solve that ? Or create a web filter correctly ?</p>