title: @WebFilter exclude url-pattern
body: <p>I use a filter to check URL patterns for the logged in user.</p>
  
  <p>But I have many URL patterns I need to filter.</p>
  
  <pre><code>{ "/table/*", "/user/*", "/contact/*", "/run/*", "/conf/*", ..., ..., ...}
  </code></pre>
  
  <p>It's becoming unmaintainable. It will be simpler just to exclude:</p>
  
  <pre><code>{ "/", "/login", "/logout", "/register" }
  </code></pre>
  
  <p>How can I achieve this?</p>
  
  <pre><code>@WebFilter(urlPatterns = { "/table/*","/user/*", "/contact/*","/run/*","/conf/*"})
  public class SessionTimeoutRedirect implements Filter {
  
      protected final Logger logger = LoggerFactory.getLogger("SessionFilter");
  
      @Override
      public void doFilter(ServletRequest req, ServletResponse res,
              FilterChain chain) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) req;
          HttpServletResponse response = (HttpServletResponse) res;
          if (request.getSession().getAttribute("Id") != null) {
              chain.doFilter(req, res);
          } else {
              logger.debug("session is null:"+request.getRequestURL());                    
              response.sendRedirect(request.getContextPath()+"/login");
          }
      }
  
      @Override
      public void init(FilterConfig arg0) throws ServletException {
  
      }
  
      @Override
      public void destroy() {
  
      }
  
  }
  </code></pre>