public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
          HttpServletRequest req = (HttpServletRequest) request;

          if (req.getRequestURI().equals(req.getContextPath() + "/")) {
            if (needsToCreateFirstUser()) {
              ((HttpServletResponse) response).sendRedirect("securityRealm/firstUser");
            } else { // the first user already created. the role of this filter is over.
              PluginServletFilter.removeFilter(this);
              chain.doFilter(request, response);
            }
          } else chain.doFilter(request, response);
        }
  @Override
  public Filter createFilter(FilterConfig filterConfig) {

    try {
      PluginServletFilter.removeFilter(filter);
      PluginServletFilter.addFilter(filter);

    } catch (ServletException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }

    return super.createFilter(filterConfig);
  }