<%@ 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: deltree

Deletes a directory and all its contents.

example 1 - delete a dir under the Web app's tempdir

<gnat:deltree dir="<%= dirname %>" />


Note: this example makes the directory first, using the mkdir tag, so you don't get an exception if the dir doesn't exist. <% String dirname = tempdir.toString() + "/foo2dir"; %> <%-- If you want to invoke an exception, just for testing... --%> <%-- --%> <%-- If you want to invoke another exception with a different cause and message, just for testing... --%> <%-- --%>