ebook img

J2EE FrontEnd Technologies: A Programmer’s Guide to Servlets, JavaServer Pages, and Enterprise JavaBeans PDF

1109 Pages·2002·34.997 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview J2EE FrontEnd Technologies: A Programmer’s Guide to Servlets, JavaServer Pages, and Enterprise JavaBeans

J2EE FrontEnd Technologies: A Programmer's Guide to Servlets, JavaServer Pages, and Enterprise JavaBeans LENNART JGRELID APress Media, LLC J2EE FrontEnd Technologies: A Programmer's Guide to Servlets, JavaServer Pages, and Enterprise JavaBeans Copyright ©2002 by Lennart Jorelid Originally published by Apress in 2002 AII rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written perrnission of the copyright owner and the publisher. ISBN 978-1-893115-96-5 ISBN 978-1-4302-1148-8 (eBook) DOI 10.1007/978-1-4302-1148-8 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit ofthe trademark owner, with no intention ofinfringement ofthe trademark. Editorial Directors: Dan Appleman, Gary Cornell, Jason Gilmore, Karen Watterson Marketing Manager: Stephanie Rodriguez Technical Reviewers: Janet Traub, Steve Clase, David Czarnecki Project Manager: Carol Burbo Developmental Editor: Valerie Perry Copy Editors: Kim Wimpsett, Tom Gillen Production Editor: Tory McLearn Compositor: Susan Glinert Indexer: Julie Kawabata Cover Designer: Tom Debolski Artist: Alian Rasmussen In the United States, phone 1-800-SPRINGER, email orders@springer-ny. corn, or visit http://www.springer-ny.corn. Outside the United States, fax +49 6221 345229, email orders@springer. de, or visit http://www.springer.de. For information on translations, please contact Apress directly at 901 Grayson Street, Suite 204, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, email info@apress. corn, or visit http: 1/ www. apress .corn. The information in this book is distributed onan "as is" hasis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author nor Apress shall hav e any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. For Camilla and Lotta Contents at a Glance Acknowledgments ...................................................................................................... xi About the Author .................................................................................................. xiii Part I Servlets ........................................................................... 1 Chapter 1 Servlet Theory .......................................................................... 3 Chapter 2 Sharing Servlet Resources .............................................. 125 Chapter 3 Servlet Examples ................................................................. 185 Part II JSP ................................................................................... 275 Chapter 4 JavaServer Pages ................................................................. 277 Chapter 5 JSP Tag Libraries ............................................................... 363 Chapter 6 JSP Examples .......................................................................... 451 Part III Struts ............................................................................ 527 Chapter 7 The Apache Struts Framework Walkthrough ............... 529 Part IV EJB ................................................................................... 607 Chapter 8 Integrating with the Business Tier .......................... 609 Chapter 9 Example 1: Centralizing Exchange Rates ................. 745 Chapter 10 Example 2: Refactoring an Old-Style Web Application ................................................................. 791 Chapter 11 Example 3: Entity EJBs for Database Integration ................................................................................ 847 Part V Appendix ....................................................................... 987 Appendix A The Java 2 Enterprise Edition Reference Implementation Server .......................................................... 989 Index .................................................................................................... 1085 Contents Acknowledgments .............................................................................................. xi About the Author .......................................................................................... xiii Part I Servlets ....................................................................... 1 Chapter 1 Servlet Theory ..................................................................... 3 What Are Servlets ? ............................................................................................... 3 The J2EE Approach to Servlets ........................................................................ 5 Touring the javax. servlet Package ............................................................. 25 Touring the javax.servlet.http Package .................................................. 78 Maintaining State in an HTTP Connection .............................................. 120 Chapter 2 Sharing Servlet Resources ....................................... 125 What Are the Forwarding and Including Patterns? ............................ 126 Leading-Edge Patterns-in a State of Flux ............................................ 127 Sharing Resources between Servlets-A UML Approach ........................ 158 Sharing a PingerServlet Resource ............................................................. 165 Chapter 3 Servlet Examples .............................................................. 185 Shopping Cart Servlet ..................................................................................... 185 The Servlet Mediator (HTTP Tunneling Servlet) ................................. 217 Proceeding with Your Servlet Development.. .......................................... 273 Contents Part II JSP ................................................................................. 275 Chapter 4 JavaServer Pages ............................................................... 277 Why JavaServer Pages? ..................................................................................... 277 Creating a JSP Document ................................................................................. 278 Chapter 5 JSP Tag Libraries ............................................................ 363 Describing Tags ................................................................................................... 363 The Life Cycle of a Tag Handler Class ................................................... 369 IterationTag Interface .................................................................................... 374 Touring the javax.servlet.jsp. tagext Package .................................. .423 The Role of JSP Tag Libraries in Middle-Tier System Development .................................................... 447 Chapter 6 JSP Examples ......................................................................... 451 Using JSP Standard Objects ........................................................................... 451 Custom JSP Tags-Nesting and Looping ...................................................... .477 The If-Then-Else Custom JSP Tag Example .............................................. 506 Part III Struts ........................................................................ 527 Chapter 7 The Apache Struts Framework Walkthrough .................................................. 529 Overview of the Struts Architecture ....................................................... 529 Struts Controller Components ...................................................................... 540 Struts Model Components ................................................................................. 550 Struts View Components .................................................................................... 558 The View and JSP Documents ........................................................................... 587 Error Handling in the Survey Wizard Application ............................. 602 Reflections on the Struts Framework Walkthrough Example ................ 604 viii Contents Part IV EJB ................................................................................. 607 Chapter 8 Integrating with the Business Tier ............... 609 Reviewing the Structure of a J2EE Application ................................. 609 Advantages of Using a Separate Business Logic Layer ................... 610 The EJB Development Process ........................................................................ 616 The EJB Life Cycle ............................................................................................ 679 EJB Deployment Descriptors .......................................................................... 684 Touring the javax.ejb Package .................................................................... 723 Chapter 9 Example 1: Centralizing Exchange Rates .................................. 745 Using a Stateless Session EJB Component .............................................. 745 Chapter 10 Example 2: Refactoring an Old-Style Web Application ............................... 791 The View of the Old-Style Web Application ......................................... 792 The Model of the Old-Style Web Application ....................................... 797 Creating a Generic EJB Facade for the Database .............................. 811 The LegacyFacade EJB Component Deployment Descriptor ................. 828 The Web Application Deployment Structure ............................................ 844 Chapter 11 Example 3: Entity EJBs for Database Integration ......................................... 847 Step l-JNDI Registry Cleanup ...................................................................... 848 Step 2-DataSource Schema Modification .................................................. 849 Step 3-Implementing the Image Subsystem .............................................. 852 Step 4-Configuring the Image Subsystem ................................................ 909 Step 5-Implementing the WebPage Search System Classes ............... 924 Step 6-Configuring the WebPage Search System ................................... 974 Reflections on the Second Refactoring Step ....................................... 984 ix Contents Part V Appendix ................................................................... 987 Appendix A The Java 2 Enterprise Edition Reference Implementation Server ........................ 989 Configuring the Server .................................................................................... 992 Deploying J2EE Application Components ............................................... 1005 Application Deployment in the J2EE 1.3 Reference Implementation Server ................................... 1050 Configuring the J2EEv1.3 Server .............................................................. 1052 Deploying J2EE Application Components ................................................. 1054 Index ................................................................................................................... 1085 x Acknowledgments THIs BOOK HAS HAD a long and complex writing process. The specifications of all the topics covered have changed at least once during the project. Despite my constant effort to modify the text and images to reflect the changes, the many people who had a part in the book's development have accepted change with a smile. At Apress, I would like to thank Gary Cornell, Grace Wong, and Carol Burbo for believing in the project and providing structure to the writing process. Special thanks to the technical editors Janet Traub, Steve Close, and David Czarnecki who provided invaluable assistance in the development process. Many thanks to the editors Valerie Perry, Tom Gillen, and Kim Wunpsett who read, pondered, and suggested restructuring. Their skills are what separate my scattered bursts of infor mation from the quality structure of this book. For an infinite patience and the ever-present warm smile despite my prolonged absence from social and worldly events, my grateful thanks go to Camilla, Lars, and Margareta. For relatives, friends, and family to whom I must have been a complete stranger during this project, I direct my most mischievous apologies. xi

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.