JSP Examples and Best Practices - Patzer_ Andrew.pdf

(5380 KB) Pobierz
30369306 UNPDF
JSP Examples and Best Practices
by Andrew Patzer
ISBN: 1590590201
This useful resource covers JSP, Servlets, JUnit, JMeter, Ant, CVS, Customer Tags, and
JavaBeans, and provides plenty of source code.
1
TEAM FLY PRESENTS
30369306.008.png 30369306.009.png
Table of Contents
JSP Examples and Best Practices
Introduction
Chapter 1
JSP Foundations
Chapter 2
Using JSP
Chapter 3
Role Separation with Javabeans
Chapter 4
Role Separation with Custom Tags
Chapter 5
Development Using Patterns
Chapter 6
The Decorating Filter Pattern
Chapter 7
The Front Controller Pattern
Chapter 8
The View Helper Pattern
Chapter 9 -
Testing Techniques
Chapter 10 -
Deployment Techniques
Chapter 11 -
Application Frameworks
Chapter 12
Putting it all Together
Index
List of Figures
List of Tables
List of Listings
2
TEAM FLY PRESENTS
 
30369306.010.png
JSP Examples and Best Practices
ANDREW PATZER
Copyright ?2002 by Andrew Patzer
All 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
permission of the copyright owner and the publisher.
ISBN (pbk): 1-59059-020-1
Printed and bound in the United States of America 12345678910
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 of the trademark owner, with no intention of
infringement of the trademark.
Technical Reviewer: David Czarnecki
Editorial Directors: Dan Appleman, Peter Bl ackburn, Gary Cornell, Jason Gilmore, Karen Watterson, John Zukowski
Managing Editor: Grace Wong
Project Manager: Alexa Stuart
Copy Editor: Kim Wimpsett
Production Editor: Kari Brooks
Compositor: Impressions Book and Journal Services, Inc.
Indexer: Carol Burbo
Cover Designer: Tom Debolski
Marketing Manager: Stephanie Rodriguez
Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY, 10010
and outside the United States by Springer-Verlag GmbH & Co . KG, Tiergartenstr. 17, 69112 Heidelberg, Germany.
In the United States, phone 1-800-SPRINGER, email < orders@springer-ny.com >, or visit http://www.springer-
ny.com .
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 2560 9th Street, Suite 219, Berkeley, CA 94710.
Phone 510 -549 -5930, fax: 510 -549 -5939, email < info@apress.com > , or visit http://www.apress.com .
The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in
the preparation of this work, neither the author nor Apress shall have 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.
The source code for this book is available to readers at http://www.apress.com in the Downloads section.
About the Author
Andrew Patzer is a web architect for the Centare Group, a consulting firm located in the Midwest. His first book, Professional
Java Server Programming (Wrox Press, 1999), is a best seller and one of the first books to cover J2EE technologies. Andrew
recently served as a lead systems architect for a leading application service provider in the insurance industry, and he was
3
TEAM FLY PRESENTS
30369306.001.png 30369306.002.png 30369306.003.png 30369306.004.png
directly in volved in designing and building a J2EE development framework upon which the company's key product was built.
Andrew has delivered several presentations over the years to local user groups as well as national conferences.
I'd like to dedicate this book to my wife, Beth, and our daughters, Ashley and Emily. Once again, they've been very supportive
of me as I took on another book. I know it's been difficult at times to put up with me not being around because I had more
writing to do. Thank you for your love and continued support.
I'd like to give special thanks to both my mother and my mother-in-law. They've both had to deal with cancer this past year and
continue to fight. I've learned a great deal personally from both of them about courage and strength. I pray they continue to
enjoy life to its fullest each and every day.
Acknowledgments
I BELIEVE STRONGLY that a person can only go so far unless they surround themselves with good people. Over the years,
I've had the pleasure of working with some outstandi ng people. I'd like to specifically mention a few that I worked with at
Workscape (now Riverwood Solutions). Mike Schenk, Mike Connor, and Craig Wohlfeil are each extremely talented architects
who not only taught me a great deal, but also pushed me to achi eve more than I could have on my own.
Dave Glyzewski, owner of the Centare Group, has always been a friend and has done his best to support me over the years as
my career has taken me many different places. I'd like to thank Dave for being in my corner and always believing in me.
Thanks, Smithers!
John Carnell, my perpetual coworker, has been there to keep my competitive juices flowing. We always seem to push each
other to new heights (although I can't seem to push you past that five-foot mark— sorry, I couldn't help myself). Seriously, thank
you for being a friend, as well as competitor, throughout my career.
I'd also like to thank my friend Scott Borth. Scott is the only person I've found who will laugh at my jokes and find humor in the
same things I do. When your job has you sitting in front of a computer screen all day, it helps to talk to someone who not only
allows you to be yourself, but actually encourages it.
About the Technical Reviewer
David Czarnecki is a computer scientist in the Advanced Computing Technologies lab at the GE Global Research Center in
Niskayuna, New York. He's involved with various projects ranging from the development of application frameworks to the use
of natural language processing techniques. He's the coauthor of Java Internationalization (O'Reilly, 2001), and he regularly
provides expertise on how to properly internationalize software. David is also a speaker at national co nferences such as
JavaOne.
4
TEAM FLY PRESENTS
30369306.005.png 30369306.006.png
Introduction
When I wrote my first book covering JavaServer Pages and Java Servlet technology, there was
a great deal of uncharted territory to cover. Today, much of what I wrote is not only outdated,
but completely obsolete. The technology has grown tremendously fast and, with it, a legion of
Java developers eager to stay on the cutting edge of Java development. Although this is
certainly a good thing, it does however create a problem. Quite often, in a rush to implement
the latest technology, little thought is given to good design and architecture.
This book attempts to provide a framework for developing quality software using JavaServer
Pages technology. Chapters 1 and 2 lay the groundwork for using JSP. Chapters 3 and 4
explore the separation of roles between page designer and Java developer using both
JavaBeans and custom tag extensions. Chapters 5 , 6 , 7 , and 8 present several design patterns
for the presentation tier. These patterns are applied using JavaServer Pages and Java Servlets.
Chapters 9 and 10 walk through the basics of testing and deploying web applications using
open-source tools. The book concludes with the development of an application framework
along with a complete reference implementation in Chapters 11 and 12 .
I hope you enjoy this book as much as I've enjoyed writing it!
5
TEAM FLY PRESENTS
 
30369306.007.png
Zgłoś jeśli naruszono regulamin