Directory taglib ver. 1.9


    Custom JSP tag Directory lets you display and proceed content for any directory on your server. Tag executes own body for each file in the specified directory. Within tag's body you may use predefined page scope variables for access to attributes of current file (name, size, last modification date). Tag lastFile lets you select a file with the most fresh modification date.

For example:
 


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

Root directory
<get:Directory path="/" >
   File: <%=fileName%>
   Size: <%=fileSize%> bytes
   Modified: <%=fileDate%>
</get:Directory>

in this example tag prints all files for root directory

You can provide a pattern for file names also. E.g.:
 


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

<!-- specified files only -->
<get:Directory path="/" pattern="A*.doc">
   
   ...
   
</get:Directory>

You can restrict file area and proceed files with the specified extension (extensions) only. E.g. let we display .zip and .jar files only:
 


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

Archives in root directory
<get:Directory path="/" ext="zip,jar">
   
   ...
   
</get:Directory>

Latest updated zip file is <lastFile path="/" pattern="*.zip">

Tags are:

Directory

Body tag. Executes own body for each file in the given directory. Parameters are:

1) path source path
2) ext Optional parameter. Describes a commas separated list of extensions.
3) pattern Optional parameter. Describes a pattern for names of searched files.
4) fileName Optional parameter. Describes a name for page scope variable with the name of current file. Type is java.lang.String. Default value is fileName.
5) fileSize Optional parameter. Describes a name for page scope variable with the size of current file. Type is java.lang.Long. Default value is fileSize.
6) fileDate Optional parameter. Describes a name for page scope variable with the date of last modification date for current file. Type is java.util.Date. Default value is fileDate.
7) scanFiles Optional parameter. Possible values are true or false. Lets you scan or skip files. Default value is true (scan files).
8) scanDir Optional parameter. Possible values are true or false. Lets you scan or skip sub-directories. Default value is true (scan sub-directories too).
9) sort Optional parameter. Describes how to sort data. Possible values are 1 (order by name ascending) or 2 (order by last modified date descending). Default value is empty (unsorted data).

lastFile

Lets you obtain a name for the last modified file in the given directory. Parameters are:

1) path source path
2) pattern Optional parameter. Describes a pattern for names of searched files.
3) id Optional parameter. Describes a name for page scope variable for data (type is java.lang.String). Without this parameter tag just prints data.

randomFile

Lets you obtain a name for the random file in the given directory. Parameters are:

1) path source path
2) pattern Optional parameter. Describes a pattern for names of searched files.
3) id Optional parameter. Describes a name for page scope variable for data (type is java.lang.String). Without this parameter tag just prints data.

for downloading:

Library: dirtag.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags suite: