Table Of Content01 559575 FM.qxd 3/2/04 3:53 PM Page i
Jakarta Struts
FOR
DUMmIES
‰
by Mike Robinson and
Ellen Finkelstein
01 559575 FM.qxd 3/2/04 3:53 PM Page iv
01 559575 FM.qxd 3/2/04 3:53 PM Page i
Jakarta Struts
FOR
DUMmIES
‰
by Mike Robinson and
Ellen Finkelstein
01 559575 FM.qxd 3/2/04 3:53 PM Page ii
Jakarta Struts For Dummies®
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
Copyright © 2004 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
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 Publisher, 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-8600. Requests to the Publisher for permission should be addressed to the Legal Department,
Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447,
e-mail: [email protected].
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related trade
dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United
States and other countries, and may not be used without written permission. All other trademarks are the
property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor
mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP
RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE
CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CRE
ATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CON
TAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE
UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A
COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE
AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION
OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FUR
THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE
INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY
MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK
MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT
IS READ.
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 books in a variety of electronic formats. Some content that appears in print may
not be available in electronic books.
Library of Congress Control Number: 2004101960
ISBN: 0-7645-5957-5
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1O/RZ/QT/QU/IN
01 559575 FM.qxd 3/2/04 3:53 PM Page iii
About the Authors
Mike Robinson has been working in the computing field since, well, when
minicomputers were popular. He has a master’s degree in computer science
and has been an independent Java developer specializing in interactive Web
applications since 1998. Mike is an adjunct faculty member in the Computer
Science Department at Maharishi University of Management in Fairfield, Iowa.
If he had any spare time, he would probably spend it hiking.
Ellen Finkelstein is the author of numerous best-selling computer books on
AutoCAD, PowerPoint, Flash, and most recently OpenOffice.org. She writes
regular articles on AutoCAD and PowerPoint in magazines, e-zines, and for
Web sites. She is an adjunct Instructor of Management, teaching e-business
courses to M.B.A. students. She writes at home so that she can take the bread
out of the oven on time.
01 559575 FM.qxd 3/2/04 3:53 PM Page iv
01 559575 FM.qxd 3/2/04 3:53 PM Page v
Dedication
To MMY, for explaining the organizing power of Natural Law that sustains the
existence and evolution of the entire universe and showing us how to make use
of this power in our daily lives to achieve maximum results through minimum
effort.
Authors’ Acknowledgments
Mike Robinson
First and foremost I have to thank my co-author, Ellen Finkelstein, who initiated
me into the ins and outs of writing a book. Ellen is the epitome of cool under
the pressure of deadlines. She always manages to have a great sense of humor
and shiny outlook regardless of the situation. Thanks for your patience.
Thanks to my wife, Pat, who is always my guiding inspiration.
Ellen Finkelstein
I’d like to start out by thanking Mike Robinson for his extensive knowledge and
experience, clear thinking, integrity, sense of responsibility, and great flexibility.
Mike is the fountain of knowledge for this book. He is always a pleasure to work
with.
Thanks to my husband, Evan, and kids, Yeshayah and Eliyah (who want to
see their names in a book), who support me while I’m writing, writing, and
writing some more.
Collectively
At Wiley, our esteemed publisher, we’d like to thank Terri Varveris, our acqui
sitions editor, for her ever-lively support. Both Linda Morris and Susan Pink
were our able project editors, keeping track of innumerable details, including
chapters, figures, and by how many pages we were over our quota. They kept
us on track and made it easy.
Thanks to Peter Just, our friend and colleague, who did a thorough and care
ful job of technical editing, making sure that our terms and code were correct
and that we were consistent and clear. He also contributed the material for
Chapter 5.
01 559575 FM.qxd 3/2/04 3:53 PM Page vi
Publisher’s Acknowledgments
We’re proud of this book; please send us your comments through our online registration form
located at www.dummies.com/register/.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and Production
Media Development
Project Coordinator: Nancee Reeves
Project Editors: Susan Pink and Linda Morris
Layout and Graphics: Andrea Dahl,
Acquisitions Editor: Terri Varveris Lauren Goddard, Denny Hager,
Lynsey Osborn, Heather Ryan,
Technical Editor: Peter Just
Jacque Schneider
Editorial Manager: Carol Sheehan
Proofreaders: Andy Hollandbeck,
Permissions Editor: Laura Moss Carl William Pierce,
Media Development Manager: TECHBOOKS Production Services
Laura VanWinkle Indexer: TECHBOOKS Production Services
Media Development Supervisor:
Richard Graves
Editorial Assistant: Amanda Foxworth
Cartoons: Rich Tennant (www.the5thwave.com)
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Joyce Pepple, Acquisitions Director
Composition Services
Gerry Fahey, Vice President of Production Services
Debbie Stailey, Director of Composition Services
01 559575 FM.qxd 3/2/04 3:53 PM Page vii
Contents at a Glance
Introduction .................................................................1
Part I: Getting to Know Jakarta Struts ..........................7
Chapter 1: Starting with the Basics .................................................................................9
Chapter 2: Laying the Groundwork ...............................................................................25
Chapter 3: Creating a Simple Web Application with Struts ........................................47
Part II: Starting from the Core ....................................89
Chapter 4: Controlling with the Controller ..................................................................91
Chapter 5: Creating the Model .....................................................................................109
Chapter 6: Designing the View .....................................................................................137
Chapter 7: Setting the Configuration ..........................................................................159
Part III: Expanding Your Development Options ...........189
Chapter 8: Exceptions to the Rule ...............................................................................191
Chapter 9: Getting Friendly with Plug-ins ...................................................................209
Chapter 10: Getting a Helping Hand with Tag Libraries ...........................................225
Chapter 11: Working with Page Composition Techniques .......................................249
Chapter 12: Securing Your Application ......................................................................265
Part IV: Putting It All Together .................................279
Chapter 13: Logging Your Actions ...............................................................................281
Chapter 14: Creating the MusicCollection.com Application ....................................287
Part V: The Part of Tens ...........................................327
Chapter 15: Ten Helpful Extensions to Struts ............................................................329
Chapter 16: Ten Ways to Find More Information .......................................................337
Part VI: Appendixes .................................................345
Appendix A: Struts-EL and JSTL Tag Library Syntax .................................................347
Appendix B: Glossary ...................................................................................................375
Index .......................................................................379