code: @Override
      public void doFilter(ServletRequest inRequest, ServletResponse inResponse, FilterChain inFilterChain) throws IOException, ServletException {
  
          HttpServletRequest servletRequest = (HttpServletRequest) inRequest;
          HttpServletResponse servletResponse = (HttpServletResponse) inResponse;
  
          String remoteUser = servletRequest.getRemoteUser();
          HttpSession session = servletRequest.getSession(false);
          if (remoteUser != null && session != null) {
              inRequest.setAttribute("userIsActivated", Boolean.TRUE);
              inFilterChain.doFilter(inRequest, inResponse);
          } else {
              servletResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
          }
      }
docs: Sets the request attribute and passes the request and response onto the
  next filter. If there is no session or the remote user is not set,
  the response status is set to 400 (Bad Request).
  
  @param inRequest the HTTP request.
  @param inResponse the HTTP response.
  @param inFilterChain the filter chain.
  @throws IOException if there is an error in subsequent filters or in
  the subsequent response.
  @throws ServletException if there is an error in subsequent filters.