code: public static String buildUrl(
  		ServletContext servletContext,
  		HttpServletRequest request,
  		HttpServletResponse response,
  		String href,
  		HttpParameters params,
  		boolean hrefAbsolute,
  		LastModifiedServlet.AddLastModifiedWhen addLastModified
  	) throws MalformedURLException, UnsupportedEncodingException {
  		String responseEncoding = response.getCharacterEncoding();
  		String servletPath = Dispatcher.getCurrentPagePath(request);
  		href = ServletUtil.getAbsolutePath(servletPath, href);
  		href = HttpParametersUtils.addParams(href, params, responseEncoding);
  		href = LastModifiedServlet.addLastModified(servletContext, request, servletPath, href, addLastModified);
  		if(!hrefAbsolute && href.startsWith("/")) {
  			String contextPath = request.getContextPath();
  			if(contextPath.length()>0) href = contextPath + href;
  		}
  		href = encodeUrlPath(href, responseEncoding);
  		href= response.encodeURL(href);
  		if(hrefAbsolute && href.startsWith("/")) href = ServletUtil.getAbsoluteURL(request, href);
  		return href;
  	}
docs: Performs all the proper URL conversions along with optionally adding a lastModified parameter.
  This includes:
  <ol>
  <li>Converting any page-relative path to a context-relative path starting with a slash (/)</li>
  <li>Adding any additional parameters</li>
  <li>Optionally adding lastModified parameter</li>
  <li>Converting any context-relative path to a site-relative path by prefixing contextPath</li>
  <li>Encoding any non-ASCII characters in the URL path</li>
  <li>Rewrite with response.encodeURL</li>
  </ol>