<%@ page import="java.io.File" errorPage="err.jsp" %> <%@ taglib uri="gnat" prefix="gnat" %> <%-- Use the Servlet 2.2+ temporary working directory to demo some file stuff. Makes it easier because the user doesn't have to configure anything and I don't have to worry about file system and user permissions for the demo. See section 3.7 of Servlet 2.3 spec for description of this attribute. --%> <%! File tempdir = null; %> <% tempdir = (File)application.getAttribute("javax.servlet.context.tempdir"); %> Gnat JSP Taglib

Gnat Taglib: ls

Gets a directory listing as a String array named "list."

example 1 - ls


<ul>
<gnat:ls dir="<%= tempdir.toString() %>" id="list">
<li><i><font color="blue"><jsp:getProperty name="list" property="item" /></font></i></li>
</gnat:ls>
</ul> <%-- Be careful with this tag -- you can use it to list the contents of any directory on your filesytem unless you take security measures with a Java policy file. --%>

looping through a directory and formatting the file names in HTML.

File listing for <%= tempdir %>