![MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Скачать руководство пользователя страница 311](http://html1.mh-extra.com/html/macromedia/coldfusion-4-5-developing-web/coldfusion-4-5-developing-web_develop-manual_3286369311.webp)
Chapter 18: Building Custom CFAPI Tags
285
The Java implementation of
ZipBrowser
is as follows:
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 ( !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 ) ;
// read the zip file and build a query from its contents
ZipInputStream zin =
new ZipInputStream( new FileInputStream(strArchive) ) ;
ZipEntry entry ;
while ( ( entry = zin.getNextEntry()) != null )
{
// 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() ;
}
// close the archive
zin.close() ;
}
}
Содержание COLDFUSION 4.5-DEVELOPING WEB
Страница 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Страница 14: ...xiv Developing Web Applications with ColdFusion...
Страница 26: ...xxvi Developing Web Applications with ColdFusion...
Страница 34: ...8 Developing Web Applications with ColdFusion...
Страница 70: ...44 Developing Web Applications with ColdFusion...
Страница 84: ...58 Developing Web Applications with ColdFusion...
Страница 114: ...88 Developing Web Applications with ColdFusion...
Страница 148: ...122 Developing Web Applications with ColdFusion...
Страница 174: ...148 Developing Web Applications with ColdFusion...
Страница 208: ...182 Developing Web Applications with ColdFusion...
Страница 244: ...218 Developing Web Applications with ColdFusion...
Страница 274: ...248 Developing Web Applications with ColdFusion...
Страница 288: ...262 Developing Web Applications with ColdFusion...
Страница 300: ...274 Developing Web Applications with ColdFusion...
Страница 350: ...324 Developing Web Applications with ColdFusion...
Страница 362: ...336 Developing Web Applications with ColdFusion...