@ Nonnull public static String getPathWithinServletContext ( @ Nonnull final HttpServletRequest aHttpRequest ) { ValueEnforcer . notNull ( aHttpRequest , "HttpRequest" ) ; final String sRequestURI = getRequestURI ( aHttpRequest ) ; if ( StringHelper . hasNoText ( sRequestURI ) ) { // Can e.g. happen for "Request(GET //localhost:90/)" if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Having empty request URI '" + sRequestURI + "' from request " + aHttpRequest ) ; return "/" ; } // Always use the context path final String sContextPath = ServletContextPathHolder . getContextPath ( ) ; if ( StringHelper . hasNoText ( sContextPath ) || ! sRequestURI . startsWith ( sContextPath ) ) return sRequestURI ; // Normal case: URI contains context path. final String sPath = sRequestURI . substring ( sContextPath . length ( ) ) ; return sPath . length ( ) > 0 ? sPath : "/" ; }
Return the URI of the request within the servlet context .