Custom JSP tags. This library supports manipulations with server side files. copyFile copies file on your server. Parameters are: 1) source. Describes a path to source file
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- copy file c:\a.txt to c:\tmp --> <file:copyFile source="c:\\a.txt" target="c:\\tmp"/> xcopy copies directory (and sub-directories) on your server. Parameters are: 1) source. Describes a path to source directory
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- copy directory c:\tmp\user to c:\users\guest --> <file:xcopy source="c:\\tmp\\user" target="c:\\users\\guest"/> moveFile moves file on your server. Parameters are: 1) source. Describes a path to source file
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- move file c:\a.txt to c:\tmp --> <file:moveFile source="c:\\a.txt" target="c:\\tmp"/> deleteFile deletes file on your server. Parameter is: 1) source. Describes a path to source file for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- delete file c:\a.txt --> <file:deleteFile source="c:\\a.txt"/> writeFile Body tag writes data to the file on your server. Data may be defined as a parameter for this tag and/or as a body of this tag. Parameters are: 1) source Describes a path to source file
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- write string to c:\a.txt -->
<!-- append string to c:\a.txt -->
<!-- write xml code into c:\a.txt -->
createDirectory creates a directory on your server. Parameter is: 1) source. Describes a path to new directory for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- create directory c:\tmp\a --> <file:createDirectory source="c:\\tmp\\a"/> deleteDirectory deletes a directory on your server. Parameter is: 1) source. Describes a path to your directory for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- delete directory /tmp/a --> <file:deleteDirectory source="<%=getSevletConfig().getServletContext().getRealPath(\"/tmp/a\")%>" /> rename renames file (directory). Parameters are: 1) oldName Describes an old name
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- rename c:\tmp\a to c:\tmp\b --> <file:rename oldName="c:\\tmp\\a" newName="c:\\tmp\\b" /> isFile Body tag. Tests file and executes own body if file exits. Parameters are: 1) source. Describes a path to your file
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- tests file and prints true or false --> <file:isFile source="c:\\tmp\\a.txt"/> <!-- tests file and prints nothing but creates a Boolean variable b -->
<!-- do something with existing file -->
isNotFile Body tag. Tests file and executes own body if file does not exit. Parameters are: 1) source. Describes a path to your file
isDirectory Body tag. Tests directory and executes own body if directory exists. Parameters are: 1) source. Describes a path to your directory
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <!-- tests directory and prints true or false --> <file:isDirectory source="c:\\tmp"/> <!-- tests directory and prints nothing but creates a Boolean variable b -->
size Prints/returns size of file. Parameters are: 1) source. Describes a path to your file
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <file:size source="c:/tmp/myfile.pdf"/> <!-- saves data in the page scope variable -->
lastModified Prints/returns 'last modified' date. Parameters are: 1) source. Describes a path to your file/directory
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <file:lastLastModified source="c:/tmp/myfile.pdf"/> <file:lastModified source="c:/tmp/file.zip" format="dd/MM/yyyy hh:mm"/> <!-- saves date in the page scope variable -->
setLastModified Changes 'last modified' date. Parameters are: 1) source. Describes a path to your file/directory
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <file:setLastLastModified source="c:/tmp/myfile.pdf"/> forEachLine Body tag executes own body for the each line in text file. The nested page scope variable line (type is java.lang.String) describes the current line. Parameters are: 1) source Describes a name for your file for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <file:forEachLine source="c:/tmp/myfile.txt"> Line is <%=line%> </file:forEachLine> readFile Tag lets you read text file and save content in the page scope variable or just print it as is. Parameters are: 1) source Describes a name for your file
for example:
<%@ taglib uri="taglib.tld" prefix="file" %> <file:readFile source="/WEB-INF/web.xml"/> for downloading: Library: filetags.jar Description: taglib.tld See also Coldtags suite - the largest collection of custom JSP tags. |
Also in Coldtags:
|