Zipbrowser Example - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

ZipBrowser Example

ColdFusion processes the page 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
objects. The example uses the
called
The tag's
browse. The tag's
The returned query contains three columns: Name, Size, and Compressed.
For example, to query an archive at the path C:\logfiles.zip for its contents and
output the results, you use the following CFML code:
<cfx_ZipBrowser
<cfoutput query="LogFiles">
#Name#,
</cfoutput>
The Java implementation of
import com.allaire.cfx.* ;
import java.util.Hashtable ;
import java.io.FileInputStream ;
import java.util.zip.* ;
public class ZipBrowser implements CustomTag
{
which is a zip file browsing tag.
ZipBrowser,
attribute specifies the fully qualified path of the zip archive to
archive
attribute must specify the query to return to the calling page.
name
archive="C:\logfiles.zip"
name="LogFiles" >
#Size#, #Compressed# <BR>
public void processRequest( Request request, Response response )
throws Exception
{
// validate that required attributes were passed
if (
!request.attributeExists( "ARCHIVE" ) ||
!request.attributeExists( "NAME" ) )
{
throw new Exception(
"Missing attribute (ARCHIVE and NAME are both " +
"required attributes for this tag)" ) ;
}
// get attribute values
String strArchive = request.getAttribute( "ARCHIVE" ) ;
String strName = request.getAttribute( "NAME" ) ;
// create a query to use for returning the list of files
String[] columns = { "Name", "Size", "Compressed" } ;
int iName = 1, iSize = 2, iCompressed = 3 ;
Query files = response.addQuery( strName, columns ) ;
Request
package to implement a Java CFX
java.util.zip
is as follows:
ZipBrowser
,
, and
Response
Query
397

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents