private String getRedirectUrl ( HttpServletRequest request , String newScheme ) { String serverName = request . getServerName ( ) ; String uri = request . getRequestURI ( ) ; StringBuilder redirect = new StringBuilder ( 100 ) ; redirect . append ( newScheme ) ; redirect . append ( "://" ) ; redirect . append ( serverName ) ; redirect . append ( uri ) ; String query = request . getQueryString ( ) ; if ( query != null ) { redirect . append ( ' ' ) ; redirect . append ( query ) ; } return redirect . toString ( ) ; }
Return the full URL that should be redirected to including query parameters .