@ Nonnull public static String getRequestServletPath ( @ Nullable final HttpServletRequest aRequest ) { String ret = "" ; if ( aRequest != null ) try { if ( aRequest . isAsyncSupported ( ) && aRequest . isAsyncStarted ( ) ) ret = ( String ) aRequest . getAttribute ( AsyncContext . ASYNC_SERVLET_PATH ) ; else ret = aRequest . getServletPath ( ) ; } catch ( final UnsupportedOperationException ex ) { // Offline request - fall through } catch ( final Exception ex ) { // fall through if ( isLogExceptions ( ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "[ServletHelper] Failed to determine servlet path of HTTP request" , ex ) ; } return ret ; }
Get the servlet path of an request supporting sync and async requests .