static String getServletPath ( HttpServletRequest request ) { String servletPath = request . getServletPath ( ) ; if ( hackWorks && PACKAGE . equals ( request . getClass ( ) . getPackage ( ) . getName ( ) ) ) { try { Object outer = get ( request , "this$0" ) ; Object servletPipeline = get ( outer , "servletPipeline" ) ; Object servletDefs = get ( servletPipeline , "servletDefinitions" ) ; int length = Array . getLength ( servletDefs ) ; for ( int i = 0 ; i < length ; ++ i ) { Object pattern = get ( Array . get ( servletDefs , i ) , "patternMatcher" ) ; if ( matches ( pattern , servletPath ) ) { servletPath = extractPath ( pattern , servletPath ) ; break ; } } } catch ( Exception e ) { hackWorks = false ; } } return servletPath ; }
Helper to get the servlet path for the request .