code: private String getBaseUrl(String pUrl, String pServletPath) {
          String sUrl;
          try {
              URL url = new URL(pUrl);
              String host = getIpIfPossible(url.getHost());
              sUrl = new URL(url.getProtocol(),host,url.getPort(),pServletPath).toExternalForm();
          } catch (MalformedURLException exp) {
              sUrl = plainReplacement(pUrl, pServletPath);
          }
          return sUrl;
      }
docs: Strip off everything unneeded