code: public static String getRelativeUrl(HttpServletRequest request, boolean servlet) {
          // Raw request url
          String requestURI = request.getRequestURI();
          // Application (war) context path
          String contextPath = request.getContextPath();
          // Servlet mapping
          String servletPath = request.getServletPath();
  
          String relativeUrl = requestURI;
  
          // Remove application context path
          if (contextPath != null && relativeUrl.startsWith(contextPath)) {
              relativeUrl = relativeUrl.substring(contextPath.length());
          }
  
          // Remove servlet mapping path
          if (servlet && servletPath != null && relativeUrl.startsWith(servletPath)) {
              relativeUrl = relativeUrl.substring(servletPath.length());
          }
  
          if (LOG.isDebugEnabled()) {
              LOG.debug("requestURI: {}, contextPath: {}, servletPath: {}, relativeUrl: {}, ", requestURI, contextPath,
                      servletPath, relativeUrl);
          }
  
          return relativeUrl;
      }
docs: Get the relative url to the current servlet.
  <p>
  Uses the request URI and removes : the context path, the servlet path if used.
  
  @param request
  The current HTTP request
  @param servlet
  true to remove the servlet path
  @return the url, relative to the servlet mapping.