public static String getRequestURL ( HttpServletRequest req , boolean includeQueryString ) { StringBuffer sb = req . getRequestURL ( ) ; int maxpos = sb . indexOf ( "/" , 8 ) ; if ( maxpos > - 1 ) { if ( req . isSecure ( ) ) { if ( sb . substring ( maxpos - 4 , maxpos ) . equals ( ":443" ) ) sb . delete ( maxpos - 4 , maxpos ) ; } else { if ( sb . substring ( maxpos - 3 , maxpos ) . equals ( ":80" ) ) sb . delete ( maxpos - 3 , maxpos ) ; } if ( includeQueryString && ! StringUtil . isEmpty ( req . getQueryString ( ) ) ) sb . append ( ' ' ) . append ( req . getQueryString ( ) ) ; } return sb . toString ( ) ; }
returns the full request URL