code: public String getAbsoluteUri(String relativeUri, String baseUri) {
  
          if ((relativeUri == null) || (relativeUri.charAt(0) == '/') || (relativeUri.startsWith("#"))) {
  
              return relativeUri;
          }
  
          // if we are on a windows system, we must add a ":" in the uri later
          String windowsAddition = "";
          if (File.separator.equals("\\")) {
              windowsAddition = ":";
          }
  
          try {
              URL baseUrl = new URL("file://");
              URL url = new URL(new URL(baseUrl, "file://" + baseUri), relativeUri);
              if (url.getQuery() == null) {
                  if (url.getRef() == null) {
                      return url.getHost() + windowsAddition + url.getPath();
                  } else {
                      return url.getHost() + windowsAddition + url.getPath() + "#" + url.getRef();
                  }
              } else {
                  return url.getHost() + windowsAddition + url.getPath() + "?" + url.getQuery();
              }
          } catch (MalformedURLException e) {
              return relativeUri;
          }
      }
docs: Calculates an absolute uri from a relative "uri" and the given absolute "baseUri".<p>
  
  If "uri" is already absolute, it is returned unchanged.
  This method also returns "uri" unchanged if it is not well-formed.<p>
  
  @param relativeUri the relative uri to calculate an absolute uri for
  @param baseUri the base uri, this must be an absolute uri
  @return an absolute uri calculated from "uri" and "baseUri"