public class DirectoryListingCGI extends Object implements IncludeCgiPrintInterface
DirectoryListingCGI class lists a directory of files
as specified by the tag element DIR relative the server
directory (not htdocs).
It also contains a static method that other CGI's may call to produce this directory listing depending e.g. of a client certificate that implies a private directory on the server for the particular client.
A typical document would look like:
(html)
(head)
(meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1")
(title)Directory listing(/title)
(style)
(!--
td { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 60%; }
--)
(/style)
(body)
(h2)Directory (%@include cgi="DIRLIST" dirname=1)(/h2)
(table border cellspacing=1 cellpadding=1)
(tr)
(td bgcolor="#C0C0C0")(b)Name(/b)(/td)
(td bgcolor="#C0C0C0" align="center")(b)Size(/b)(/td)
(td bgcolor="#C0C0C0" align="center")(b)Date(/b)(/td)
(/tr)
(%@include cgi="DIRLIST"
dir ="."
fileref ="/download.cgi"
tr ="(tr)"
tdparent="(td)(pdir) "
tddir ="(td)(dir) "
tdfile ="(td)(file) "
tdsize ="(td align='right')"
tddate ="(td)")
(/table)
(/body)
(/html)
FileDownloadCGI| Constructor and Description |
|---|
DirectoryListingCGI() |
| Modifier and Type | Method and Description |
|---|---|
static void |
listDirectory(HttpSession session,
Element element,
String dir,
PrintWriter out)
Prints the directory listing to the print writer.
|
void |
performAction(HttpSession session,
HttpResource resource,
Element element,
PrintWriter out)
Prints the directory listing from the base directory as specified
by the DIR element.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitformatIPResult, formatIPResult, queryLocationInfo, queryLocationInfo, queryLocationInfopublic void performAction(HttpSession session, HttpResource resource, Element element, PrintWriter out) throws IOException
If the element DIRNAME=1 is specified, the subdirectory name
specified in the URL as parameter is returned, e.g.
(h2)Directory (%@include cgi="DIRLIST" dirname=1)(/h2)
The following elements are used to build the table:
performAction in interface IncludeCgiPrintInterfacesession - The current HTTP session.resource - The HTTP resource for which the CGI is being executed.element - The HTML element where this CGI is included in.out - The PrintWriter to which the part of the HTML document should be printed to.IOException - for IO errors.public static void listDirectory(HttpSession session, Element element, String dir, PrintWriter out)
fileRef is null or empty, no hyperlinks
for the files will be created.Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© 2026 Mindus SARL. All rights reserved.