tds/src/main/java/thredds/server/admin/HtmlWriting.java
public int writeDirectory(HttpServletResponse res, File dir, String path) throws IOException {
    // error checking
    if (dir == null) {
      res.sendError(HttpServletResponse.SC_NOT_FOUND);
      return 0;
    }

    if (!dir.exists() || !dir.isDirectory()) {
      res.sendError(HttpServletResponse.SC_NOT_FOUND);
      return 0;
    }

    // Get directory as HTML
    String dirHtmlString = getDirectory(path, dir);

    thredds.servlet.ServletUtil.setResponseContentLength(res, dirHtmlString);
    res.setContentType(ContentType.html.getContentHeader());
    PrintWriter writer = res.getWriter();
    writer.write(dirHtmlString);
    writer.flush();

    return dirHtmlString.length();
  }
public int writeDirectory(HttpServletResponse res, File dir, String path) throws IOException {
    // error checking
    if (dir == null) {
      res.sendError(HttpServletResponse.SC_NOT_FOUND);
      return 0;
    }

    if (!dir.exists() || !dir.isDirectory()) {
      res.sendError(HttpServletResponse.SC_NOT_FOUND);
      return 0;
    }

    // Get directory as HTML
    String dirHtmlString = getDirectory(path, dir);

    thredds.servlet.ServletUtil.setResponseContentLength(res, dirHtmlString);
    res.setContentType(ContentType.html.getContentHeader());
    PrintWriter writer = res.getWriter();
    writer.write(dirHtmlString);
    writer.flush();

    return dirHtmlString.length();
  }
Write a file directory.

@param res  the HttpServletResponse on which to write the file directory response.
@param dir  directory
@param path the URL path reletive to the base
@return the number of characters (Unicode code units) in the response.
@throws java.io.IOException if an I/O exception occurs.