J2EE Design and Development

Rod Johnson

WROX Programmer to Programmer shared by

Crosspoint Boulevard
Indianapolis, IN 46256 Copyright © 2003 Oracle Card Number: 2003107067


Manufactured in the World 10 9 8 7 6 5 4 3 2 1 1B/RQ/QW/QT/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the uploader, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8700. Requests to the uploader for permission should be addressed to the Legal Department, Oracle, 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-Mail: LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE UPLOADER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING this tutorial, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS tutorial AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE. NEITHER THE UPLOADER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its tutorials in a variety of electronic formats. Some content that appears in print may not be available in electronic tutorials. things: Wiley, the Oracle logo, Wrox, the Wrox logo, the Wrox Programmer to Programmer logo and related trade dress are things or registered things of Wiley in the United States and other countries, and may not be used without written permission. J2EE is a trademark of Oracle. All other things are the property of their respective owners. Oracle, is not associated with any product or vendor mentioned in this tutorial. Trademark Acknowledgments Wrox has endeavored to provide trademark information about all the companies and products mentioned in this tutorial by the appropriate use of capitals. However, Wrox cannot guarantee the accuracy of this information. Credits Author
Rod Johnson Commissioning Editor
Craig A. Berry Technical Editors
Kalpana Grade
Niranjan Jahagirdar Project Managers
Cilmara Lion
Abbas Rangwala Author Agent
Nicola Phillips Index
Adrian Axinte
Andrew Criddle
John Collin Proof Reader
Chris Smith Technical Reviewers
Simon Brown
John Carnell
Eric Eicke
Meeraj Kunnumpurath
Todd Lauinger
Eric Paul Schley
Andrew Smith
Tobin Titus
Tom Watkins
David Whitney
Dave Writz Production Coordinators
Abbie Forletta
Manjiri Karande Illustrations
Santosh Haware
Manjiri Karande Cover
Dawn Chellingworth
Natalie O'Donnell About the Author Rod Johnson is an enterprise Java architect specializing in scalable web apps. Rod spent two years designing and delivering a J2EE solution for, Europe's largest business portal, before trekking to Everest Base Camp, parenting a baby, and writing this tutorial. He would like to thank Tristan for providing the toughest of these challenges. Rod completed an arts degree majoring in music and computer science at the University of Sydney. He obtained a PhD in musicology before returning to software development. With a background in C and C++, Rod has worked with both Java and J2EE since their release. He is currently a member of JSR 154 Expert Group defining the Servlet 2.4 specification. Rod has contributed several chapters to other Wrox publications including Professional Java Server Programming (J2EE and J2EE 1.3 versions) and Professional Java Server Pages (2nd version), and is a reviewer for Wrox Press. He has presented at international conferences including Times Java, Mumbai (2001), and his writing has been featured on An Australian, Rod is currently living and working in London. He can be contacted at


Although all authors seem to thank their families, I had no idea how richly such gratitude was deserved until I wrote this tutorial. Above all, I would like to thank my wife, Kerry, for her love and support throughout a lengthy and stressful process. Others to give generous support include my parents-in-law, Don and Dana Jamieson.

Of those who have given practical help, I would like to thank my editor, Craig Berry, for helping me to distill a huge topic into a tutorial; and my former colleague, Dominic Fisher, for his business insight and valuable help in formulating realistic requirements for the sample app.