uri = request.getContextPath() + uri;
} else if (uri.charAt(0) == '~') {
final int j = uri.indexOf('/', 1);
final String ctxroot =
j >= 0 ? "/" + uri.substring(1, j): "/" + uri.substring(1);
final ExtendletContext extctx =
Servlets.getExtendletContext(ctx, ctxroot.substring(1));
if (extctx != null) {
uri = j >= 0 ? uri.substring(j): "/";
return extctx.encodeRedirectURL(
request, response, uri, params, mode);
} else {
uri = len >= 2 && uri.charAt(1) == '/' ?
uri.substring(1): '/' + uri.substring(1);
}