if ( fragment != null ) uri.setFragment( uri.encode( fragment ) );
boolean needsToBeSecure = needsToBeSecure( servletContext, request, uri.getPath(), true );
URLRewriterService.rewriteURL( servletContext, request, response, uri, URLType.ACTION, needsToBeSecure );
String key = getURLTemplateKey( URLType.ACTION, needsToBeSecure );
URIContext uriContext = URIContextFactory.getInstance( forXML );
return URLRewriterService.getTemplatedURL( servletContext, request, uri, key, uriContext );
}