code: public static final String getRelativeURI( String contextPath, String uri )
      {
          String requestUrl = uri;
          int overlap = requestUrl.indexOf( contextPath + '/' );
          assert overlap != -1 : "contextPath: " + contextPath + ", uri: " + uri;
          return requestUrl.substring( overlap + contextPath.length() );
      }
docs: Get a URI relative to a given webapp root.
  
  @param contextPath the webapp context path, e.g., "/myWebapp"
  @param uri the URI which should be made relative.