public static void getAbsoluteURL ( HttpServletRequest request , String relPath , Appendable out ) throws IOException { out . append ( request . isSecure ( ) ? "https://" : "http://" ) ; out . append ( request . getServerName ( ) ) ; int port = request . getServerPort ( ) ; if ( port != ( request . isSecure ( ) ? 443 : 80 ) ) out . append ( ' ' ) . append ( Integer . toString ( port ) ) ; out . append ( request . getContextPath ( ) ) ; out . append ( relPath ) ; }
Gets an absolute URL for the given context - relative path . This includes protocol port context path and relative path . No URL rewriting is performed .