User Guide
284 Developing Web Applications with ColdFusion
your CustomTag object. If you wish to store data and/or objects that are accessible to all
instances of your
CustomTag you should use static data members.
Calling the CFX from a ColdFusion Template
You call Java CFXs from within ColdFusion templates by using the name of the CFX.
The following CFML template calls the
HelloColdFusion custom tag:
<HTML>
<BODY>
4 <CFX_HelloColdFusion NAME="Les">
</BODY>
</HTML>
To test the CFX:
1. Create a new source file in your editor and enter the code displayed above.
2. Save the file in a directory configured to serve ColdFusion templates. For example,
you might save the file as c:\inetpub\wwwroot\cfdocs\testjavacfx.cfm on
Windows NT or
/home/docroot/cfdocs/testjavacfx.cfm on UNIX.
3. Request the template from your web browser using the appropriate URL, for
example
http://localhost/cfdocs/testjavacfx.cfm
ColdFusion processes the template and returns a page that displays the text "Hello,
Robert." If an error is returned instead, check the source code to make sure you have
entered it correctly.
ZipBrowser Example
The following example illustrates the use of the Request, Response, and Query objects.
The example uses the
java.util.zip package to implement a Java CFX called
ZipBrowser, which is a zip file browsing tag.
The fully qualified path of the zip archive to browse is specified using the
ARCHIVE
attribute. The name of the query to return to the calling page is specified using the
NAME attribute. The query returned contains three columns: Name, Size, and
Compressed.
For example, to query an archive at the path c:\logfiles.zip for its contents and to
output the results you would use the following CFML code:
<CFX_ZipBrowser
ARCHIVE="c:\logfiles.zip"
NAME="LogFiles" >
<CFOUTPUT QUERY="LogFiles">
#Name#, #Size#, #Compressed# <BR>
</CFOUTPUT>