code: protected String getBaseUrl(final HttpServletRequest request) {
  		if (LOG.isDebugEnabled()) {
  			LOG.debug("Extract base url from " + request);
  		}
  
  		StringBuilder results = new StringBuilder();
  
  		results.append(request.getScheme());
  		results.append("://");
  		results.append(request.getServerName());
  
  		if ((!("http".equals(request.getScheme()) && (80 == request.getServerPort())))
  				&& (!("https".equals(request.getScheme()) && (443 == request.getServerPort())))) {
  			results.append(':');
  			results.append(request.getServerPort());
  		}
  
  		results.append(request.getContextPath());
  		// Make sure to strip any trailing slash
  		if (results.charAt(results.length() - 1) == '/') {
  			return results.substring(0, results.length() - 1);
  		}
  
  		return results.toString();
  	}
docs: Get the base url that corresponds to this request. For instance, if the web application is mounted in the web
  context "evisas" on the server "localhost", and the request is for the URL
  "http://localhost/evisas/some/thing/page", then the returned base url will be "http://localhost/evisas".
  
  @param request the incoming request
  @return the base url for the web application.