Gal Shachor, Adam Chace, Magnus Rydin9781930110090, 1-930110-09-X
Table of contents :
brief contents……Page 5
contents……Page 7
preface……Page 17
acknowledgments……Page 19
about this book……Page 21
author online……Page 26
about the cover illustration……Page 27
The big picture……Page 31
1.1 The JSP custom tags solution……Page 32
1.2.1 HTTP protocol……Page 33
1.3 Dynamic web servers……Page 37
1.3.1 Common Gateway Interface……Page 38
1.3.2 Web server APIs……Page 40
1.3.3 Server pages techniques……Page 41
1.3.4 Separating business and presentation logic……Page 43
1.4 Tag-based programming……Page 45
1.4.1 Benefits of a tag-based approach……Page 46
1.5 WAP, voice, and other alternative web clients……Page 47
1.6 Summary……Page 50
Web development with Java……Page 51
2.1 Java and dynamic web content……Page 52
2.2.1 The servlet API and programming model……Page 53
2.2.2 Servlets and non-Java web servers……Page 58
2.2.3 Servlet shortcomings……Page 59
2.3 Introduction to JavaServer Pages……Page 60
2.3.2 A JSP example……Page 61
2.3.3 Scriptlets……Page 62
2.3.4 Implicit variables……Page 65
2.3.5 Directives……Page 66
2.3.6 Tags……Page 68
2.3.7 Tags for JavaBean manipulation……Page 69
2.3.8 Executing a JSP page……Page 71
2.4.1 Model-1……Page 76
2.4.2 Model-2……Page 77
2.5 Servlets, JSP, and application configuration……Page 80
2.5.1 The WAR file and its structure……Page 81
2.5.2 The application deployment descriptor……Page 83
2.6 Summary……Page 85
Developing your first tags……Page 86
3.1.1 Anatomy of a tag……Page 87
3.1.2 Using a tag in JSP……Page 88
3.1.3 The tag library descriptor……Page 89
3.2 Why tags?……Page 90
3.3 Setting up a development environment……Page 91
3.3.2 Installing Tomcat……Page 92
3.3.3 Testing your Tomcat installation……Page 93
3.4 Hello World example……Page 94
3.4.1 Compiling the tag……Page 95
3.4.2 Creating a tag library descriptor (TLD)……Page 96
3.4.3 Testing HelloWorldTag……Page 97
3.4.5 A tag with attributes……Page 100
3.4.6 Packaging tags for shipment……Page 103
3.5 A tag with a body……Page 104
3.5.1 LowerCaseTag handler……Page 105
3.6 Summary……Page 107
Custom JSP tag API and life cycle……Page 108
4.1 Requirements of custom tags……Page 109
4.2 Overview of the tag API……Page 111
4.2.1 Tag interface……Page 115
4.2.2 Tag life cycle……Page 118
4.3.1 BodyTag interface……Page 122
4.4 Tag API classes……Page 125
4.4.2 PageContext class……Page 127
4.4.3 BodyContent class……Page 128
4.5.1 TryCatchFinally interface……Page 129
4.5.3 EVAL_BODY_BUFFERED , EVAL_BODY_AGAIN return codes……Page 130
4.5.4 Updated Tag life cycle……Page 131
4.6 Summary……Page 134
Integrating custom tags with the JSP runtime……Page 135
5.1 Tag library descriptor in a nutshell……Page 136
5.1.1 The role of the TLD……Page 138
5.2 Referencing a tag library from a JSP……Page 140
5.2.1 The Taglib’s uri attribute……Page 141
5.3.1 Send tag example……Page 145
5.3.2 Translating the JSP into a servlet……Page 149
5.4 Summary……Page 154
Tag development techniques……Page 157
6.1.1 The techniques you’ll use most……Page 158
6.2 Writing content back to the user……Page 160
6.2.1 Adding data to the output……Page 161
6.2.3 Flushing the JspWriter’s internal buffer……Page 165
6.3 Setting tag attributes……Page 167
6.3.1 Specifying tag attributes in the TLD……Page 168
6.3.2 Providing validity checks at translation time……Page 170
6.3.3 Using the JavaBeans coding conventions……Page 173
6.4 Logging and messaging……Page 174
6.4.2 Handling and throwing exceptions……Page 175
6.4.3 Improving logging……Page 176
6.5 Using the Servlet API……Page 178
6.5.1 Accessing the implicit JSP objects……Page 179
6.5.2 Accessing the JSP attributes……Page 188
6.6 Configuring tags and bundling resources……Page 197
6.6.1 Configuring a web application……Page 198
6.7 Working with the tag’s body……Page 204
6.7.1 Tag body evaluation……Page 205
6.7.2 Referencing your tag’s body……Page 208
6.7.3 A BodyTag example–logging messages……Page 212
6.8 Tag cooperation through nesting……Page 216
6.9 Cleaning up……Page 217
6.9.2 Exceptions and cleanup……Page 218
6.9.3 Improving our base classes to handle cleanup……Page 220
6.10 Summary……Page 222
Building a tag library for sending email……Page 223
7.1.1 The Simple Mail Transfer Protocol……Page 224
7.1.2 Java-based email……Page 225
7.2.1 SimpleJavaMailTag example……Page 228
7.3.2 Using an existing mail session……Page 234
7.3.4 An enhanced SimpleJavaMailTag: JavaMailTag……Page 235
7.3.5 The JavaMailTag in action……Page 240
7.4 Collecting attributes from the tag’s body……Page 243
7.4.2 Extending the email tag……Page 245
7.4.3 Creating tags for subject and message……Page 246
7.5 Adding assertions and input validation……Page 251
7.5.1 Performing validation using custom tags……Page 252
7.5.2 Creating a tag for the send mail tag library……Page 253
7.6 Summary……Page 261
Using JavaBeans with tags……Page 263
8.1 Java reflection……Page 264
8.1.1 What is reflection?……Page 265
8.1.2 The reflection API……Page 266
8.2.2 JavaBeans properties……Page 272
8.2.4 Properties and introspection……Page 275
8.3 The Show tag……Page 279
8.3.1 Components of the tag……Page 280
8.4.1 Informing the runtime of exported scripting variables……Page 292
8.4.2 The ExportTag……Page 298
8.5 Summary……Page 303
Posing conditions with tags……Page 307
9.1 Evaluating conditions in JSPs……Page 308
9.2 IfTag—A simple condition tag……Page 309
9.2.1 Implementing IfTag……Page 310
9.2.2 The problem with IfTag……Page 311
9.3 The advanced condition tag family……Page 313
9.3.1 WithTag……Page 315
9.3.2 TestTag……Page 318
9.3.3 TLD for the advanced condition tags……Page 324
9.3.4 Our tag library in action……Page 325
9.4 Improving our advanced condition tags……Page 327
9.4.2 Supporting complex conditions with JavaBeans……Page 328
9.5 Summary……Page 329
Iterating With Tags……Page 330
10.1 Iterating with tags 101……Page 333
10.1.1 Iteration example: SimpleForeachTag……Page 334
10.2.1 A generic iteration interface……Page 339
10.2.2 IterationTagSupport……Page 340
10.3.2 Wrapping iterators……Page 345
10.3.3 Implementing IterateTag……Page 347
10.4.1 Printing the shopping cart with scriptlets……Page 351
10.4.2 Printing the shopping cart with IterateTag……Page 353
10.5 Making it easier on the JSP author……Page 354
10.5.2 The design……Page 356
10.5.3 FieldGetter and ReflectionFieldGetter……Page 357
10.5.4 Integrating FieldGetter with IterationTagSupport……Page 358
10.5.5 Updating IterateTag to perform field substitution……Page 362
10.5.6 Field substitution in action……Page 363
10.6.1 IterationTag……Page 364
10.7 Summary……Page 366
Database access with tags……Page 368
11.1 Choosing how to present database information……Page 369
11.2 Designing our database presentation tag library……Page 370
11.2.2 Additional design considerations……Page 371
11.3 IterateResultSetTag……Page 373
11.3.1 ResultSetIterationSupport class……Page 374
11.3.2 JDBCFieldGetter class……Page 375
11.3.3 IterateResultSetTag in action……Page 376
11.4 Full JDBC connectivity through tags……Page 377
11.4.1 Improving our one-tag approach……Page 378
11.5.1 Requirements……Page 380
11.5.2 Choosing our tags……Page 382
11.6 Implementing the library……Page 385
11.6.1 DBConnectionTag……Page 386
11.6.2 SQLQueryTag……Page 393
11.6.3 EnumRsTag……Page 398
11.6.4 Using our library for the first time……Page 401
11.6.5 ViewRsTag……Page 403
11.7.1 The controller servlet……Page 408
11.7.2 The JSP……Page 410
11.8 Summary……Page 411
Custom tags and J2EE……Page 413
12.1 What is J2EE?……Page 414
12.1.1 J2EE server components and client access……Page 416
12.1.3 Why custom tags and J2EE are a good fit……Page 417
12.2.1 EJBs—What are they?……Page 418
12.2.2 Types of EJB components……Page 420
12.2.3 EJBs and their functions……Page 423
12.2.4 Example: catalogue entry EJB……Page 425
12.3 Using and configuring J2EE services……Page 434
12.3.1 Getting services……Page 435
12.3.2 Tag and servlet API integration……Page 436
12.3.3 Setting environment entries……Page 437
12.3.4 Setting EJB reference entries……Page 438
12.3.5 Setting resource factory reference entries……Page 439
12.3.6 Wrap it up……Page 440
12.4.1 DataSource……Page 441
12.4.2 Updating database tags to use J2EE conventions……Page 442
12.5.1 Defining a mail service……Page 449
12.5.2 Referencing the mail service……Page 450
12.5.3 J2EE send tag……Page 452
12.6.1 Writing custom tags for EJB access……Page 457
12.6.2 Retrieving the EJB home interface……Page 458
12.6.3 Using the EJB home interface……Page 462
12.7 Summary……Page 470
JDBC-driven WebStore……Page 473
13.1.1 Custom tags used……Page 474
13.2 Overview……Page 475
13.3 Requirements……Page 476
13.4.1 Model……Page 480
13.4.2 View……Page 484
13.5 Implementation……Page 489
13.5.1 Tags……Page 490
13.5.2 Views……Page 502
13.6 Summary……Page 554
EJB-driven WAPStore……Page 555
14.1.1 Custom tags used……Page 556
14.2 Overview……Page 557
14.3.1 Normal flow of events……Page 558
14.3.2 Model……Page 559
14.3.3 View……Page 560
14.3.4 Welcome view……Page 563
14.3.5 Controller……Page 589
14.4 Summary……Page 591
JSP tag libraries— tips and tricks……Page 595
15.1.1 Tags and nonprogrammers……Page 596
15.1.2 Reusing tags……Page 597
15.1.4 Tags and application performance……Page 598
15.2.1 Tag development dos……Page 599
15.2.2 Tag development don’ts……Page 604
15.3.2 Testing tags on more than one JSP container……Page 606
15.4.1 Opening library internals……Page 607
15.4.2 Generalizing your tags……Page 608
15.4.3 Integration and the surrounding environment……Page 611
15.5.1 The tag life cycle……Page 612
15.5.3 Freeing allocated resources……Page 613
15.6 Summary……Page 614
What is XML?……Page 617
A.2 XML syntax……Page 618
A.2.1 DTDs……Page 620
A.3 XML pitfalls……Page 621
A.4 Why XML?……Page 622
A.6 Additional reading……Page 623
The Tag Library Descriptor……Page 625
B.1.1 The taglib element……Page 626
B.1.2 The tag element……Page 627
B.1.3 Element Recap……Page 629
B.2 A sample TLD……Page 630
B.3.1 New taglib elements……Page 632
B.3.2 New tag elements……Page 633
B.4 Summary……Page 635
Using the code examples……Page 636
C.1.2 Using the example tags……Page 637
C.1.3 Compiling the example tags……Page 638
C.2.1 The WebStore application……Page 639
C.2.2 The WAPStore application……Page 641
references……Page 643
index……Page 645
Reviews
There are no reviews yet.