code: public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
              throws IOException, ServletException {
  
          final HttpServletRequest req = (HttpServletRequest) request;
          final HttpServletResponse res = (HttpServletResponse) response;
  
          if (req.getServerName().equals(host)) {
              chain.doFilter(request, response);
              return;
          }
  
          res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
  
          final StringBuilder sb = new StringBuilder();
          sb.append("http");
          if (req.isSecure()) {
              sb.append("s");
          }
          sb.append("://").append(host);
          if (StringUtils.isNotBlank(req.getPathInfo())) {
              sb.append(req.getPathInfo());
          }
          if (StringUtils.isNotBlank(req.getQueryString())) {
              sb.append("?").append(req.getQueryString());
          }
          res.setHeader("Location", sb.toString());
      }
docs: Forward requests.....
  
  @param request The request object.
  @param response The response object.
  @param chain Refers to the {@code FilterChain} object to pass control to the next {@code Filter}.
  @throws IOException a IOException
  @throws ServletException a ServletException