コード例 #1
0
ファイル: Context.java プロジェクト: pedroigorsilva/is
  /** Return the absolute path for the docBase, if we are file-system based, null otherwise. */
  public String getAbsolutePath() {
    if (absPath != null) return absPath;

    if (FileUtil.isAbsolute(docBase)) absPath = docBase;
    else absPath = contextM.getHome() + File.separator + docBase;
    try {
      absPath = new File(absPath).getCanonicalPath();
    } catch (IOException npe) {
    }
    return absPath;
  }
コード例 #2
0
ファイル: Context.java プロジェクト: pedroigorsilva/is
  /**
   * @deprecated - use getDocBase and URLUtil if you need it as URL NOT USED INSIDE TOMCAT - ONLY IN
   *     OLD J2EE CONNECTORS !
   */
  public URL getDocumentBase() {
    if (documentBase == null) {
      if (docBase == null) return null;
      try {
        String absPath = docBase;

        // detect absolute path ( use the same logic in all tomcat )
        if (FileUtil.isAbsolute(docBase)) absPath = docBase;
        else absPath = contextM.getHome() + File.separator + docBase;

        try {
          absPath = new File(absPath).getCanonicalPath();
        } catch (IOException npe) {
        }

        documentBase = new URL("file", "", absPath);

      } catch (MalformedURLException ex) {
        ex.printStackTrace();
      }
    }
    return documentBase;
  }