code: public void commence(ServletRequest req, ServletResponse res) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) req;
          
          String pathInfo = request.getPathInfo();
          String queryString = request.getQueryString();
          String contextPath = request.getContextPath();
          String destination = request.getServletPath() + ((pathInfo == null) ? "" : pathInfo)
              + ((queryString == null) ? "" : ("?" + queryString));
  
          String redirectUrl = contextPath;
  
          Integer currentPort = new Integer(portResolver.getServerPort(request));
          Integer redirectPort = getMappedPort(currentPort);
  
          if (redirectPort != null) {
              boolean includePort = redirectPort.intValue() != standardPort;
  
              redirectUrl = scheme + getMappedDomain(request.getServerName()) + ((includePort) ? (":" + redirectPort) : "") + contextPath
                  + destination;
          }
  
          LOG.debug(" Cross Domain EntryPoint Redirecting to: " + redirectUrl);
  
          ((HttpServletResponse) res).sendRedirect(((HttpServletResponse) res).encodeRedirectURL(redirectUrl));
      }
docs: {@inheritDoc}