private static String deriveUsefulInfo ( HttpServletRequest httpRequest ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "[" ) . append ( httpRequest . getContextPath ( ) ) ; sb . append ( ":cookies=" ) . append ( Arrays . toString ( httpRequest . getCookies ( ) ) ) . append ( ":headers=" ) ; // Append Header information Enumeration < ? > en = httpRequest . getHeaderNames ( ) ; while ( en . hasMoreElements ( ) ) { String headerName = ( String ) en . nextElement ( ) ; sb . append ( headerName ) . append ( "=" ) ; // Ensure HTTP Basic Password is not logged if ( ! headerName . contains ( "authorization" ) ) { sb . append ( httpRequest . getHeader ( headerName ) ) . append ( "," ) ; } } sb . append ( "]" ) ; // Append Request parameter information sb . append ( "[parameters=" ) ; Enumeration < ? > enparam = httpRequest . getParameterNames ( ) ; while ( enparam . hasMoreElements ( ) ) { String paramName = ( String ) enparam . nextElement ( ) ; String [ ] paramValues = httpRequest . getParameterValues ( paramName ) ; int len = paramValues != null ? paramValues . length : 0 ; for ( int i = 0 ; i < len ; i ++ ) { sb . append ( paramValues [ i ] ) . append ( "::" ) ; } sb . append ( "," ) ; } sb . append ( "][attributes=" ) ; // Append Request attribute information Enumeration < ? > enu = httpRequest . getAttributeNames ( ) ; while ( enu . hasMoreElements ( ) ) { String attrName = ( String ) enu . nextElement ( ) ; sb . append ( attrName ) . append ( "=" ) ; sb . append ( httpRequest . getAttribute ( attrName ) ) . append ( "," ) ; } sb . append ( "]" ) ; return sb . toString ( ) ; }
Obtain debug information from the servlet request object