A guide to the topics required for state of the art Web development, this book covers wide-ranging topics, including a variety of web development frameworks and best practices. Beginning with coverage of the history of the architecture of Web applications, highlighting the uses of the standard web API to create applications with increasingly sophisticated architectures, developers are led through a discussion on the development of industry accepted best practices for architecture. Described is the history and evolution towards this architecture and the reasons that it is superior to previous efforts. Also provided is an overview of the most popular Web application frameworks, covering their architecture and use. Numerous frameworks exist, but trying to evaluate them is difficult because their documentation stresses their advantages but hides their deficiencies. Here, the same application is built in six different frameworks, providing a way to perform an informed comparison. Also provided is an evaluation of the pros and cons of each framework to assist in making a decision or evaluating a framework on your own. Finally, best practices are covered, including sophisticated user interface techniques, intelligent caching and resource management, performance tuning, debugging, testing, and Web services.
Author(s): Neal Ford
Edition: illustrated edition
Publisher: Manning
Year: 2003
Language: English
Pages: 627
brief contents......Page 9
contents......Page 11
preface......Page 19
acknowledgments......Page 21
about the book......Page 23
How this book is organized......Page 24
Notes about the samples......Page 26
Author Online......Page 30
About the author......Page 31
about the cover illustration......Page 32
Part I The evolution of web architecture and design......Page 33
State-of-the-art web design......Page 35
1.1 A brief history of Java web development......Page 36
1.2 The importance of design patterns......Page 38
1.2.1 The Model-View-Controller design pattern......Page 39
1.2.2 The emergence of Model 2......Page 41
1.2.3 Evolution......Page 42
1.3 Using frameworks......Page 43
1.3.1 A flavor of the Struts framework......Page 44
1.3.2 A flavor of the Turbine framework......Page 46
1.4.1 Business rules......Page 52
A working definition......Page 53
Placing the rules in the database server......Page 54
Rules that do belong in the database server......Page 55
1.4.3 Leveraging best practices......Page 56
1.5 Summary......Page 57
Building web applications......Page 59
2.1.1 The eMotherEarth servlet application......Page 61
The second page: Catalog......Page 62
The third page: ShowCart......Page 73
The fourth page: confirmation......Page 77
2.2 Building web applications with JSP......Page 82
The second page: Catalog......Page 83
The third page: ShowCart......Page 87
The fourth page: Confirmation......Page 90
2.2.2 Evaluating the JSP approach......Page 91
2.3 Summary......Page 92
Creating custom JSP tags......Page 93
3.1 The case for custom tags......Page 94
3.2.1 The Tag interface......Page 95
3.2.2 The IterationTag interface......Page 96
3.2.3 The BodyTag interface......Page 97
3.3.1 The HtmlSqlResult tag......Page 98
3.3.2 Registering the tag......Page 103
3.4.1 Adding DbPool to the application tag......Page 107
3.5 Using prebuilt tags......Page 112
3.5.1 Using JSTL......Page 113
3.5.2 Using other taglibs......Page 116
Other taglibs......Page 117
3.6 Custom tag considerations......Page 118
3.6.1 Resource usage......Page 119
3.7 Now that we’re here, where are we?......Page 120
3.8 Summary......Page 121
The Model 2 design pattern......Page 123
4.1 Using Model 2 as your framework......Page 124
4.1.1 The Model 2 schedule application......Page 125
Building the schedule model......Page 126
Building the ScheduleItem value object......Page 134
Building the main controller......Page 136
Building the main view......Page 137
Building the entry controller......Page 140
Building the entry view......Page 141
Building the Save controller......Page 145
Disadvantages of Model 2......Page 148
4.2 Parameterizing commands with controller servlets......Page 149
4.2.1 An example of parameterizing commands......Page 150
Building the model......Page 151
The abstract Action class......Page 152
Concrete actions......Page 153
Building the generic controller......Page 157
4.2.2 Advantages and disadvantages......Page 159
4.3 Summary......Page 160
Part II Web frameworks......Page 163
Using Struts......Page 165
5.1.1 The Struts schedule application......Page 166
5.1.2 Value objects as form beans......Page 168
5.1.3 Objectifying commands with Struts’ actions......Page 169
5.1.4 Configuring Struts applications......Page 171
Struts configuration for the web application......Page 173
5.1.5 Using Struts’ custom tags to simplify JSP......Page 174
5.1.6 Internationalization with Struts......Page 177
5.1.7 Struts’ support for data entry......Page 179
Building the entry view......Page 181
5.1.8 Declarative validations......Page 183
Building the AddToScheduleAction......Page 187
5.2 Evaluating Struts......Page 188
5.3 Summary......Page 189
Tapestry......Page 191
6.2 The architecture......Page 192
The application servlet......Page 194
The application specification......Page 196
The Home page specification......Page 197
The Home page template......Page 198
Visit......Page 199
IRequestCycle......Page 201
AbstractComponent and BaseComponent......Page 202
ITableModel......Page 204
6.5.1 Bootstrapping the application......Page 205
The application specification......Page 206
The application servlet......Page 207
The Home page template......Page 208
The Hello page class......Page 210
The table template......Page 212
The table class......Page 213
The Add page specification......Page 217
The Add page template......Page 218
The Add class......Page 220
Validations......Page 223
Documentation......Page 224
Samples......Page 225
6.6.2 Debugging support......Page 227
6.6.3 Using Tapestry......Page 228
6.7 Summary......Page 229
WebWork......Page 231
7.1 Overview......Page 232
7.1.1 The architecture......Page 233
7.1.2 The configuration......Page 234
7.2 Key concepts......Page 235
7.2.2 Key interfaces......Page 236
7.2.3 The value stack......Page 237
7.2.4 Expression language......Page 238
7.2.6 Templates......Page 239
7.3.1 The configuration......Page 240
The action......Page 241
The view......Page 244
The AddScheduleBase class......Page 246
The AddScheduleItem class......Page 248
The AddSchedule view......Page 249
Saving the record......Page 251
Editors......Page 252
7.4 Evaluating WebWork......Page 256
7.5 Summary......Page 258
InternetBeans Express......Page 259
8.1 Overview......Page 260
DataExpress and JDBC......Page 262
DataModules......Page 263
8.2.2 InternetBeans Express......Page 265
8.3.1 ixPageProducer......Page 266
Handling request parameters......Page 267
8.3.2 ixComponents......Page 268
8.4 Scheduling with InternetBeans......Page 269
8.4.1 Data connectivity......Page 270
8.4.2 The View page......Page 274
The View servlet......Page 275
The View template......Page 276
The Add servlet......Page 277
The Add template......Page 280
8.4.4 Validations......Page 281
8.5 JSP custom tags......Page 287
8.6.1 Documentation and samples......Page 289
8.6.2 Using InternetBeans Express......Page 290
8.7 Summary......Page 291
Velocity......Page 293
9.1 Overview......Page 294
9.2 The architecture......Page 295
Configuration......Page 297
Instancing options......Page 298
Directives......Page 300
9.4 Scheduling with Velocity......Page 301
The Velocity servlet......Page 303
The template......Page 305
9.4.2 The Add page......Page 306
9.4.3 Validations......Page 310
9.5.1 Documentation and samples......Page 313
9.6 Summary......Page 314
Cocoon......Page 315
10.1 Overview......Page 316
10.2.1 The publishing framework......Page 317
Pipelines......Page 318
10.2.2 The web framework......Page 320
Transformations......Page 321
Transformer......Page 326
Generator configuration......Page 327
Transformers......Page 328
Actions......Page 329
Pipelines......Page 330
Actions......Page 331
XSP......Page 333
10.4 Scheduling in Cocoon......Page 334
10.4.1 The sitemap......Page 335
10.4.2 The action......Page 336
10.4.3 The view......Page 337
10.5.1 Documentation and samples......Page 339
10.5.3 Debugging......Page 340
10.6 Summary......Page 341
Evaluating frameworks......Page 343
11.1.1 Suitability to the application......Page 344
Speed of development......Page 345
Scalability......Page 346
Developer guides......Page 347
11.1.3 Source code......Page 348
11.1.4 Tool support......Page 349
Critical mass......Page 350
11.2.1 Adherence to good design principles......Page 351
Ease of use......Page 352
11.2.3 Innovative features......Page 353
11.2.5 “Feel”......Page 354
11.3.2 Innovative ideas......Page 355
11.4 Summary......Page 356
Part III Best practices......Page 359
Separating concerns......Page 361
12.1 Using interfaces to hide implementation......Page 362
12.1.2 Interfaces in frameworks......Page 363
12.1.3 Decoupled classes......Page 364
12.2 Using JavaBeans......Page 365
Value objects (entity classes)......Page 366
Aggregators (boundary classes)......Page 368
12.3 Using Enterprise JavaBeans......Page 369
12.3.1 The EJB architecture......Page 370
The EJB schedule application......Page 372
The EventDBBean EJB......Page 373
The EventTypeDbBean EJB......Page 378
The event entity EJB......Page 380
Business rules in session beans......Page 388
Changes to the models......Page 389
12.3.3 Using EJBs in web frameworks......Page 392
12.3.4 Managing JNDI context......Page 393
12.4.1 Client-side validations......Page 394
Scheduling with client-side validation......Page 395
Server-generated client-side validation......Page 397
12.5 Summary......Page 400
Handling flow......Page 403
Packages......Page 404
Welcome......Page 405
Catalog......Page 406
13.1.2 Page-at-a-time scrolling......Page 410
Using JSTL......Page 412
13.1.3 Sortable columns......Page 416
Using factories......Page 419
Tapestry......Page 421
13.2 Building undo operations......Page 422
Transactions in Model 2 applications......Page 423
Transactions via JSTL......Page 425
13.2.2 Using the Memento design pattern......Page 426
Creating bookmarks in eMotherEarth......Page 427
The Caretaker......Page 430
13.3.1 The difference between technical and domain exceptions......Page 433
13.3.2 Creating custom exception classes......Page 434
13.3.3 Where to catch and handle exceptions......Page 435
Rethrowing exceptions......Page 436
Empty catch blocks......Page 437
13.3.4 Exceptions in frameworks......Page 438
13.4 Summary......Page 439
Performance......Page 441
14.1.1 Measuring memory......Page 442
Using the SDK profiler......Page 444
Analyzing the results......Page 447
Using commercial profilers......Page 448
JMeter......Page 451
14.2 Common performance pitfalls......Page 453
Stateless classes......Page 454
Object reuse......Page 455
14.2.2 Extraneous object references......Page 456
14.2.3 String usage......Page 458
14.3.1 Simple object pools......Page 459
14.3.2 Soft and weak references......Page 460
Soft references......Page 462
Weak references......Page 463
14.3.3 Commons pools......Page 465
eMotherEarth with pooled boundary classes......Page 466
14.4 Designing for scalability......Page 472
14.4.2 Molding your architecture for the future......Page 473
14.5 When to optimize......Page 474
14.6 Summary......Page 475
Resource management......Page 477
15.1 Caching strategies......Page 478
15.1.1 Caching with the Flyweight design pattern......Page 479
Implementing Flyweight......Page 480
Flyweight considerations......Page 484
15.1.2 Caching with the Façade design pattern......Page 485
Automating façade creation......Page 486
Establishing the façade class......Page 489
Using façade to borrow objects......Page 490
Using the façade to return objects......Page 492
Façade benefits......Page 495
Making the façade more generic......Page 496
Generically returning boundaries......Page 499
15.1.3 Resource management in frameworks......Page 501
15.2.1 Effectively using JNDI......Page 502
15.2.3 Working with web collections......Page 504
15.3 Summary......Page 505
Debugging......Page 507
16.1 Debugging web applications......Page 508
16.2.1 Starting the debugger......Page 515
16.2.2 Running the debugger......Page 518
16.2.3 Breakpoints and steps......Page 521
16.2.4 Accessing variables......Page 522
16.2.5 Effectively using jdb......Page 524
Starting the debugger......Page 525
Watches......Page 526
Breakpoints......Page 528
Debugging with NetBeans......Page 529
Projects......Page 530
Starting the debugger......Page 533
Investigating values......Page 534
Evaluate and modify......Page 535
16.4 Evaluating debuggers......Page 537
16.5.1 Struts......Page 538
16.5.4 InternetBeans Express......Page 539
16.6 Logging......Page 540
Hierarchies......Page 541
Levels......Page 542
Formatting......Page 543
Logging eMotherEarth with the SDK......Page 544
Logging eMotherEarth with log4j......Page 548
16.6.5 Logging in frameworks......Page 551
16.7 Summary......Page 552
Unit testing......Page 553
17.1.1 Agile development......Page 554
17.1.2 Unit testing in web applications......Page 556
17.2.2 Testing entities......Page 557
17.2.3 Running tests......Page 560
17.2.4 Test suites......Page 561
17.2.5 Testing boundaries......Page 562
17.2.6 Tool support......Page 566
Automating regression testing......Page 567
17.3 Web testing with JWebUnit......Page 568
17.3.1 JWebUnit TestCases......Page 569
17.3.2 Testing complex elements......Page 571
17.4 Summary......Page 573
Web services and Axis......Page 575
18.1 Key concepts......Page 576
18.2 Axis......Page 577
18.2.1 Architecture of Axis......Page 578
Simple web services......Page 579
WSDL2Java......Page 581
18.3 Calling web services......Page 583
Changes to web.xml......Page 585
Database connections......Page 586
Server.config......Page 587
18.4.2 Orders......Page 588
Order boundary......Page 589
The orders web service......Page 590
18.4.3 Calling the web service......Page 591
Calling the web service from other languages......Page 593
18.5 Summary......Page 594
What won’t fit in this book......Page 595
19.1.2 Enterprise JavaBeans......Page 596
19.1.3 Java data objects (JDO)......Page 597
19.2 HTML and the user interface......Page 598
19.2.2 Cascading Style Sheets......Page 599
19.3 JavaScript......Page 600
19.4 Summary......Page 601
bibliography......Page 602
index......Page 603