Temporary objects taglib ver. 1.2

    Custom JSP taglib. Lets you create temporary directories and files. All such objects will be deleted automatically, as soon as session is closed (invalidated).

You can place objects in the temporary area provided by your container (as per Servlets API 2.2) or directly provide a path for directory (file). You can describe name for created objects or tags will generate some unique names. Result of operation (an absolute path for directory or file) will be printed or saved in new page scope variable.

For example:
 


<%@ taglib uri="taglib.tld" prefix="temp" %>

<!-- create temp directory in system area with unique name -->
<temp:CreateTempDirectory id="A"/>
Directory is <%=A%>

<!-- create temp sub-directory -->
<temp:CreateTempDirectory path="c:/tmp" id="A"/>

<!-- create temp sub-directory with name work -->
<temp:CreateTempDirectory path="/home/tmp" name="work" id="A"/>

the same for files:
 


<%@ taglib uri="taglib.tld" prefix="temp" %>

<!-- create temp file in system area with unique name -->
<temp:CreateTempFile id="A"/>
File is <%=A%>

<!-- create temp file in /home/users with name work.txt -->
<temp:CreateTempFile path="/home/users" name="work.txt" id="A"/>

Tags are:

CreateTempDirectory

Creates temporary (auto-deleted) directory. Parameters are:

1) path Optional parameter. Describes a path for directory, where temp object will be created. Without this parameter tag uses temporary area defined by container.
2) name Optional parameter. Describes name for directory. Without this parameter some unique name will be generated.
3) id Optional parameter. Describes name for page scope variable. An absolute path for new object will be saved here. Type is java.lang.String. Without this parameter tag just prints data.

CreateTempFile

Creates temporary (auto-deleted) file. Parameters are:

1) path Optional parameter. Describes a path for directory, where temp object will be created. Without this parameter tag uses temporary area defined by container.
2) name Optional parameter. Describes name for file. Without this parameter some unique name will be used.
3) id Optional parameter. Describes name for page scope variable. An absolute path for new object will be saved here. Type is java.lang.String. Without this parameter tag just prints data.

for downloading:

Library: temptag.jar    Description: taglib.tld

© Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.