// Add all the parameters and reset the href attribute; pass to false here because
// the HtmlTagSupport will HtmlEncode the ampersands for us
String base = getPreferredBaseUrl();
UrlBuilder builder = new UrlBuilder(pageContext.getRequest().getLocale(), base, false);
if (this.event != VALUE_NOT_SET) {
builder.setEvent(this.event == null || this.event.length() < 1 ? null : this.event);
}
if (addSourcePage) {
builder.addParameter(StripesConstants.URL_KEY_SOURCE_PAGE,
CryptoUtil.encrypt(request.getServletPath()));
}
if (this.anchor != null) {
builder.setAnchor(anchor);
}
builder.addParameters(this.parameters);
// Prepend the context path, but only if the user didn't already
String url = builder.toString();
String contextPath = request.getContextPath();
if (contextPath.length() > 1) {
boolean prepend = prependContext != null && prependContext
|| prependContext == null && beanclass != null
|| prependContext == null && url.startsWith("/") && !url.startsWith(contextPath);