static public String getRealPath ( String servletUrl , String extUrl ) { Pattern pat = Pattern . compile ( "^https??://[^/]*" ) ; // Deal with potential bad extUrl formats Matcher m = pat . matcher ( extUrl ) ; if ( m . find ( ) ) { extUrl = m . group ( 0 ) ; } String retval = pat . matcher ( servletUrl ) . replaceFirst ( extUrl ) ; return retval ; }
Simple utility method deal with a request that has the wrong URL when behind a proxy .