Apache Jakarta Commons Iverson FM.Qxd 1/17/05 6:03 PM Page Ii
Total Page:16
File Type:pdf, Size:1020Kb
Iverson_FM.qxd 1/17/05 6:03 PM Page i Apache Jakarta Commons Iverson_FM.qxd 1/17/05 6:03 PM Page ii BRUCE PERENS’ OPEN SOURCE SERIES http://www.phptr.com/perens ◆ Java™ Application Development on Linux® Carl Albing and Michael Schwarz ◆ C++ GUI Programming with Qt 3 Jasmin Blanchette and Mark Summerfield ◆ Managing Linux Systems with Webmin: System Administration and Module Development Jamie Cameron ◆ Understanding the Linux Virtual Memory Manager Mel Gorman ◆ PHP 5 Power Programming Andi Gutmans, Stig Bakken, and Derick Rethans ◆ Implementing CIFS: The Common Internet File System Christopher Hertel ◆ Open Source Security Tools: A Practical Guide to Security Applications Tony Howlett ◆ Embedded Software Development with eCos Anthony Massa ◆ Rapid Application Development with Mozilla Nigel McFarlane ◆ The Linux Development Platform: Configuring, Using, and Maintaining a Complete Programming Environment Rafeeq Ur Rehman and Christopher Paul ◆ Intrusion Detection with SNORT: Advanced IDS Techniques Using SNORT, Apache, MySQL, PHP, and ACID Rafeeq Ur Rehman ◆ The Official Samba-3 HOWTO and Reference Guide John H. Terpstra and Jelmer R. Vernooij, Editors ◆ Samba-3 by Example: Practical Exercises to Successful Deployment John H. Terpstra Iverson_FM.qxd 1/17/05 6:03 PM Page iii Apache Jakarta Commons Reusable Java™ Components Will Iverson Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris Madrid • Capetown • Sydney • Tokyo • Singapore • Mexico City Iverson_FM.qxd 1/17/05 6:03 PM Page iv Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U. S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the U. S., please contact: International Sales [email protected] Visit us on the Web: www.phptr.com Library of Congress Catalog Number: 2004115288 Copyright © 2005 Pearson Education, Inc. Pearson Education, Inc. Rights and Contracts Department One Lake Street Upper Saddle River, NJ 07458 ISBN 0-13-147830-3 Text printed in the United States on recycled paper at R.R. Donnelley & Sons Company in Crawfordsville, Indiana. First printing: February 2005 Iverson_FM.qxd 1/17/05 6:03 PM Page v For Cynthia. Iverson_FM.qxd 1/17/05 6:03 PM Page vi Iverson_FM.qxd 1/17/05 6:03 PM Page vii Contents Preface . .xiii Acknowledgments . .xvi About the Author . .xvii 1 Overview . .1 Proper Versus Sandbox . .2 License . .4 Obtaining and Installing . .4 Configuration Under Eclipse . .5 From Here . .9 2FileUpload . .11 Web and User Interfaces . .11 FileUpload Design . .13 Building an Application with FileUpload . .16 FileUpload Application User Interface . .16 Sample FileUpload Application Code . .17 Application Presentation . .18 Application Logic . .20 Limitations and Security Issues . .26 Summary . .27 3 HttpClient . .29 A Simple Cookie-Based Web Site . .31 Understanding HttpClient . .32 Simple Swing Client . .37 Swing Client User Interface . .37 Swing Client Code . .38 Summary . .43 vii Iverson_FM.qxd 1/17/05 6:03 PM Page viii viii Contents 4Net . .45 Net Overview . .46 FTP Functionality . .48 FTP Implementation . .49 NNTP Functionality . .54 NNTP Implementation . .56 Summary . .66 5Pool . .67 Interfaces and Implementation . .69 Thread Pool Example . .69 Object Factory Example . .74 Worker Thread . .75 Summary . .77 6 DBCP (Database Connection Pool) . .79 Standalone DataSources . .81 Client Connectivity . .81 Building the DataSource . .83 Legacy JDBC Driver . .86 Summary . .89 7 BeanUtils . .91 Understanding BeanUtils . .93 Using BeanUtils to Generate Forms . .94 Sample JavaBeans . .95 Presenting the Form . .95 FormBean . .97 FormBeanUtils . .101 Summary . .103 8 JXPath . .105 Setting Up the Example Object Graph . .107 Exploring the Hierarchy . .110 XPath and JXPath Syntax . .113 Basic XPath . .113 Complex XPath . .114 JXPath Extensions . .115 Supported Data Types . .116 Summary . .117 9 Logging . .119 Trace Levels . .119 Using Logging . .120 Logging Output . ..