code: private String convertURItoURL(String uri) {
          int indexScheme = uri.indexOf("://");
          if (-1 != indexScheme) {
              int indexQuery = uri.indexOf('?');
              if (-1 == indexQuery || indexScheme < indexQuery) {
                  // already a full url
                  return uri;
              }
          }
          StringBuilder sb = new StringBuilder();
          String scheme = this.request.getScheme();
          sb.append(scheme).append("://");
          sb.append(this.request.getServerName());
          int port = this.request.getServerPort();
          if ("http".equalsIgnoreCase(scheme) && 80 != port) {
              sb.append(':').append(port);
          } else if ("https".equalsIgnoreCase(scheme) && 443 != port) {
              sb.append(':').append(port);
          }
          String data = this.request.getContextPath();
          if (!"".equals(data)) {
              sb.append(data);
          }
          if (0 == uri.length()) {
              sb.append('/');
          } else if (uri.charAt(0) == '/') {
              // relative to servlet container root...
              sb.append(uri);
          } else {
              // relative to current URI,
              data = this.request.getServletPath();
              if (!"".equals(data)) {
                  sb.append(data);
              }
              data = this.request.getPathInfo();
              if (null != data) {
                  sb.append(data);
              }
              sb.append('/');
              sb.append(uri);
              // TODO: webcontainer converted "/./" and "/../" info too
          }
  
          return sb.toString();
      }
docs: Convert a possible URI to a full URL.
  
  @param uri
  @return String