MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual page 311

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 18: Building Custom CFAPI Tags
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
{
public void processRequest( Request request, Response response )
throws Exception
{
// validate that required attributes were passed
if (
{
}
// 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 ) ;
// read the zip file and build a query from its contents
ZipInputStream zin =
ZipEntry entry ;
while ( ( entry = zin.getNextEntry()) != null )
{
}
// close the archive
zin.close() ;
}
}
ZipBrowser
!request.attributeExists( "ARCHIVE" ) ||
!request.attributeExists( "NAME" ) )
throw new Exception(
"Missing attribute (ARCHIVE and NAME are both " +
"required attributes for this tag)" ) ;
new ZipInputStream( new FileInputStream(strArchive) ) ;
// add a row to the results
int iRow = files.addRow() ;
// populate the row with data
files.setData( iRow, iName,
entry.getName() ) ;
files.setData( iRow, iSize,
String.valueOf(entry.getSize()) ) ;
files.setData( iRow, iCompressed,
String.valueOf(entry.getCompressedSize()) ) ;
// finish up with entry
zin.closeEntry() ;
is as follows:
285

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents