Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
4Activity
0 of .
Results for:
No results containing your search query
P. 1
JakartaStrutsLive

JakartaStrutsLive

Ratings: (0)|Views: 14 |Likes:
Published by api-3794526

More info:

Published by: api-3794526 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Jakarta Struts Live
by Richard Hightower

Copyright \u00a9 2004 by SourceBeat, LLC.
Cover Copyright \u00a9 2004 by SourceBeat, LLC.
All rights reserved.

Published by SourceBeat, LLC, Highlands Ranch, Colorado.

Managing Editor: James Goodwill
Technical Editor: Kelly Clauson
Copy Editor:

Brent Barkley
Layout Designer: Amy Kesic
Cover Designer:

Max Hays
ISBN: 0974884308

Many designations used by organizations to distinguish their products are claimed as trademarks. These trademarked names may appear in this book. We use the names in an editorial fashion only with no intention of infringing on the trademark; therefore you will not see the use of a trademark symbol with every occurrence of the trademarked name.

As every precaution has been taken in writing this book, the author and publisher will in no way
be held liable for any loss or damages resulting from the use of information contained in this
book.

Jakarta Struts Live

Dedication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix About the Author. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii

Chapter 1: Struts Quick Start Tutorial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Download Struts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Set up a J2EE Web Application Project That Uses Struts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Write Your First Action. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Write Your First \u201cForward\u201d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Configure the Action and Forward in the Struts Configuration File. . . . . . . . . . . . . . . . . . . . . . . . . . 7
Run and Test Your First Struts Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Debug Struts-Config.xml with the Struts Console. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Add Logging Support with Log4J and Commons Logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Write Your First ActionForm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Write Your First Input View (JSP Page). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Update the Action to Handle the Form and Cancel Buttons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Set up the Database Pooling with Struts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Exception Handling with Struts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Display an Object with Struts Tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Using Logic Tags to Iterate over Users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Chapter 2: Testing Struts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Testing Model Code with JUnit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Getting Started with JUnit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Using JUnit Step-by-Step. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Applying JUnit to Our Struts Tutorial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Testing Struts Actions with StrutsTestCase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Using StrutsTestCase (Mock Mode) Step-by-Step. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Using StrutsTestCase (Cactus Mode). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Testing JSP with jWebUnit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Using jWebUnit Step-by-Step. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Chapter 3: Working with ActionForms and DynaActionForms. . . . . . . . . . 74

Defining an ActionForm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Understanding the Life Cycle of an ActionForm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 The Do\u2019s and Don\u2019ts of Automatic Type Conversion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Table of Contents

Activity (4)

You've already reviewed this. Edit your review.
1 hundred reads
ALi liked this
ALi liked this
rajuchal liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->