Web Development with Java Server Pages

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Dynamic content-personalized, customized, and up-to-the-minute-is a key component of site development on the World Wide Web today. Java Server Pages (JSP) is a new server-side technology for generating dynamic content in Web pages and other on-line applications. This guide to JSP covers all aspects of development and includes comparisons to similar dynamic content systems such as CGI, Active Server Pages, Cold Fusion, and PHP. Included is a discussion of the use of component centric design via Java Beans and custom tag libraries for separating the presentation of dynamic data (the layout, look, and feel) from its implementation (the code that generates it).

Author(s): Duane K Fields, Mark A Kolb
Edition: 1st
Publisher: Manning Publications
Year: 2000

Language: English
Pages: 584

contents......Page 9
brief contents......Page 7
preface......Page 19
acknowledgments......Page 21
about this book......Page 23
Code conventions......Page 26
about the authors......Page 27
author online......Page 28
about the cover illustration......Page 29
Introduction......Page 31
1.2 Evolution of dynamic content technologies......Page 32
1.2.1 Common Gateway Interface......Page 33
1.2.2 ColdFusion......Page 35
1.2.4 Server-Side JavaScript......Page 36
1.2.6 Java servlets......Page 37
1.2.7 JavaServer Pages......Page 39
1.3 JSP and Java 2 Enterprise Edition......Page 40
1.3.2 Web-based applications......Page 41
1.4.1 Performance......Page 43
1.4.2 Reusable components......Page 46
1.4.3 Separating presentation and implementation......Page 47
1.4.4 Achieving division of labor......Page 49
Fundamentals......Page 51
2.1.2 Hello, World!......Page 52
2.1.3 Hello, World! revisited......Page 53
2.1.4 Hello, World! the Bean edition......Page 55
2.1.5 Hello Real World......Page 57
2.2 Tag conventions......Page 58
2.2.2 XML-based tags......Page 59
2.3 Running JSP......Page 61
2.3.1 Adding JSP support......Page 62
2.3.2 How JSPs work......Page 63
2.3.3 Buffered output......Page 68
2.3.4 Session management......Page 70
2.3.5 Scalability......Page 73
2.3.6 Error handling......Page 76
Programming JSP scripts......Page 79
3.1 Scripting languages......Page 80
3.3.1 Page directive......Page 82
3.3.2 Include directive......Page 93
3.3.3 Tag library directive......Page 95
3.4.1 Declarations......Page 97
3.4.2 Expressions......Page 101
3.4.3 Scriptlets......Page 104
3.5.1 Conditionalization......Page 106
3.5.3 Exception handling......Page 107
3.5.4 A word of caution......Page 110
3.6.2 JSP comments......Page 111
3.6.3 Scripting language comments......Page 112
Actions and implicit objects......Page 114
4.1 Implicit objects......Page 115
4.1.1 Servlet-related objects......Page 117
4.1.2 Input/Output......Page 118
4.1.3 Contextual objects......Page 125
4.1.4 Error handling......Page 133
4.2.1 Forward......Page 134
4.2.2 Include......Page 138
4.2.4 Bean tags......Page 140
Using JSP components......Page 141
5.1.1 Component architectures......Page 142
5.1.2 Benefits of a component architecture......Page 143
5.1.3 Component design for web projects......Page 144
5.1.4 Building applications from components......Page 145
5.2 JavaBean fundamentals......Page 147
5.2.1 The different types of JavaBeans......Page 150
5.3.1 Tag-based component programming......Page 152
5.3.2 Accessing JSP components......Page 154
5.3.3 Initializing Beans......Page 162
5.3.4 Controlling a Bean’s scope......Page 169
Developing JSP components......Page 177
6.1.1 Bean conventions......Page 178
6.1.2 The Bean constructor......Page 179
6.1.3 Defining a Bean’s properties......Page 180
6.1.4 Indexed properties......Page 184
6.1.5 Boolean properties......Page 188
6.1.6 JSP type conversion......Page 189
6.1.7 Configuring Beans......Page 191
6.2.1 Example: a TimerBean......Page 192
6.2.2 A Bean that calculates interest......Page 195
6.3.1 The BeanInfo interface......Page 199
6.3.2 The Serializable interface......Page 200
6.3.3 The HttpSessionBindingListener interface......Page 201
6.3.4 Other features of the Bean API......Page 202
6.4.2 Accessing scriptlet created objects......Page 203
Working with databases......Page 208
7.1 JSP and JDBC......Page 209
7.1.1 JNDI and data sources......Page 210
7.1.2 Prepared statements......Page 211
7.2.1 Creating JSP components from table data......Page 212
7.2.2 JSPs and JDBC data types......Page 215
7.2.3 Maintaining persistent connections......Page 218
7.2.4 Handling large sets of results......Page 221
7.2.5 Transaction processing......Page 226
7.3 Example: JSP conference booking tool......Page 227
7.3.3 Design overview......Page 228
Architecting JSP applications......Page 239
8.1 Web applications......Page 240
8.1.1 Web application flow......Page 242
8.2.1 Role-based pages......Page 243
8.2.2 Building composite pages......Page 246
8.2.3 Limitations of the page-centric approach......Page 248
8.3 Servlet-centric design......Page 249
8.3.1 Hello, World—with servlets......Page 250
8.3.2 JSP and the servlet API......Page 251
8.3.3 Servlets for application control......Page 254
8.3.4 Servlets for handling application logic......Page 255
8.3.5 Servlets as single entry points......Page 256
8.3.7 Example: servlet-centric employee browser......Page 260
8.3.8 EmployeeBean......Page 262
8.3.9 FetchEmployeeServlet......Page 265
8.3.10 JSP employee list......Page 268
8.3.11 JSP page viewer......Page 269
8.4.2 JavaBeans vs. EJBs......Page 271
8.4.3 Application servers and EJB containers......Page 272
8.4.4 Application design with EJBs......Page 273
8.5.1 Application environment......Page 274
8.5.3 Performance, scalability, and availability......Page 276
8.5.4 Technical considerations......Page 277
8.5.5 Organizational considerations......Page 278
An example JSP project......Page 280
9.1.2 Application requirements......Page 281
9.1.3 Application modules......Page 283
9.1.4 Building an FAQ component......Page 284
9.2 The storage module......Page 286
9.2.2 The FaqRepository class......Page 287
9.2.3 Storage module exceptions......Page 293
9.3 The administration module......Page 294
9.3.1 The administration servlet......Page 295
9.3.2 The main menu......Page 302
9.3.3 Adding an FAQ......Page 305
9.3.4 Deleting an FAQ......Page 309
9.3.5 Updating an FAQ......Page 315
9.4.1 The FaqServlet......Page 320
9.4.2 Viewing a single FAQ......Page 322
9.4.3 Viewing all the FAQs......Page 323
9.4.4 A table of contents view......Page 324
9.4.5 Plain text view......Page 326
Deploying JSP applications......Page 327
10.1 This means WAR......Page 328
10.1.1 WAR is XML......Page 329
10.1.2 Waging WAR......Page 331
10.2 The art of WAR......Page 332
10.2.1 WAR materiel......Page 333
10.2.2 Drafting deployment descriptors......Page 337
10.3 Maintaining a WAR footing......Page 349
Performing common JSP tasks......Page 351
11.1.1 Managing cookies......Page 352
11.1.2 The Cookie class......Page 353
11.1.3 Example 1: setting a cookie......Page 354
11.1.4 Example 2: retrieving a cookie......Page 356
11.2 Creating error pages......Page 359
11.2.2 Data collection methods......Page 360
11.2.3 Sending electronic mail......Page 365
11.2.4 The error page......Page 367
11.3 Mixing JSP and JavaScript......Page 370
11.4.1 Sticky widgets......Page 374
11.4.2 Utility methods......Page 375
11.4.3 The example form......Page 377
11.4.5 Text and hidden fields......Page 379
11.4.7 Radio buttons......Page 380
11.4.8 Select boxes......Page 381
11.4.10 Form source......Page 382
11.5 Validating form data......Page 384
11.5.1 Client- and server-side validation......Page 385
11.5.2 Example: server-side validation......Page 386
11.6 Miscellaneous tasks......Page 391
11.6.1 Determining the last modification date......Page 392
11.6.2 Executing system commands......Page 393
11.6.3 Generating XML......Page 394
JSP by example......Page 396
12.1.1 The BannerBean......Page 397
12.1.2 Using the Bean......Page 398
12.2.1 The QuoteBean......Page 400
12.2.2 Using the Bean......Page 401
12.3 The Tell a Friend! sticker......Page 402
12.3.1 The sticker......Page 403
12.3.2 The MailForm page......Page 405
12.3.3 Sending the mail......Page 406
12.4.1 The Whois protocol......Page 408
12.4.3 The WhoisBean......Page 410
12.4.4 Building the front end......Page 418
12.5.1 A basic implementation......Page 421
12.5.2 An improved version......Page 424
12.6 A button to view JSP source......Page 428
12.6.1 Displaying the source......Page 429
12.6.4 Viewing source through a bookmark......Page 431
Creating custom tags......Page 433
13.1 Role of custom tags......Page 434
13.2 How tag libraries work......Page 435
13.3 Tag library descriptors......Page 438
13.3.1 Library elements......Page 439
13.3.2 Tag elements......Page 440
13.3.3 Attribute elements......Page 441
13.4.1 Tag handlers......Page 442
13.4.2 Helper classes......Page 446
13.4.3 Auxiliary classes......Page 448
13.5 Example tag library......Page 449
13.6 Content substitution......Page 450
13.7 Tag attributes......Page 452
13.8.1 URL rewriting......Page 457
13.8.2 HTML encoding......Page 461
13.9 To be continued......Page 465
Implementing advanced custom tags......Page 466
14.1.1 Interaction mechanisms......Page 467
14.1.2 Outlining tags......Page 469
14.2 Flow of control......Page 479
14.2.1 Conditionalization......Page 480
14.2.2 Iteration......Page 488
14.3 Packaging the tag library......Page 505
14.4 For further information......Page 506
Running the reference implementation......Page 507
A.2 Installation......Page 508
A.2.1 Linux......Page 509
A.2.2 Solaris......Page 510
A.2.4 Other platforms......Page 512
A.2.5 Installation notes......Page 513
A.3.1 Application directory......Page 515
A.3.3 Server configuration......Page 516
A.3.4 Verifying the application......Page 517
B.1 Browser support for Java 2......Page 519
B.2 The plug-in action......Page 521
B.2.1 Required attributes......Page 522
B.2.2 Optional attributes......Page 523
B.2.3 Parameters......Page 524
B.2.4 Fallback text......Page 525
B.3 Example: applet configuration......Page 526
C.1 Java implementations......Page 533
C.3 JSP FAQs and tutorials......Page 534
C.5 Java application servers with JSP support......Page 535
C.7 Tools for performance testing......Page 536
C.8 Mailing lists and newsgroups......Page 537
D.1 Content comments......Page 538
D.2 JSP comments......Page 539
D.3 ......Page 540
D.4 ......Page 541
D.5 ......Page 542
D.6 ......Page 543
D.7 ......Page 544
D.8 ......Page 545
D.9 ......Page 546
D.10 ......Page 547
D.11 ......Page 548
D.12 ......Page 550
D.13 ......Page 551
D.14 ......Page 552
JSP API reference......Page 554
E.2.1 Class GenericServlet......Page 555
E.2.4 Interface ServletConfig......Page 556
E.2.7 Class ServletInputStream......Page 557
E.2.9 Interface ServletRequest......Page 558
E.2.11 Interface SingleThreadModel......Page 559
E.3.1 Class Cookie......Page 560
E.3.3 Interface HttpServletRequest......Page 561
E.3.4 Interface HttpServletResponse......Page 562
E.3.7 Interface HttpSessionBindingListener......Page 564
E.4.2 Class JspEngineInfo......Page 565
E.4.5 Interface JspPage......Page 566
E.4.7 Class JspWriter......Page 567
E.4.8 Class PageContext......Page 568
E.5.1 Class BodyContent......Page 569
E.5.4 Interface Tag......Page 570
E.5.7 Class TagExtraInfo......Page 571
E.5.9 Class TagLibraryInfo......Page 572
E.5.11 Class VariableInfo......Page 573
index......Page 575