Sams Teach Yourself JavaServer Pages in 21 Days

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"

Sams Teach Yourself JavaServer Pages in 21 Days offers a proven tutorial format to teach JSP in 21 example-driven lessons. This book is for Web publishing professionals migrating to JavaServer Pages for its ability to create dynamic, interactive Web sites and separate presentation from Java code running behind the scenes. The book starts by explaining the relationship between JSP and Java Servlets and the basics of JSP functions and features. You'll then learn how JSP handles data, interacts with Java components, tracks users, and more. Later chapters discuss debugging, working with databases, XSLT and XML, using the Struts framework from Apache, handling binary data like graphics, and deploying JSP applications. Each topic is illustrated with many working examples that the reader can understand and put to work immediately. Throughout the book the author provides pointers to upcoming developments in JSP 2, to ensure that you are prepared for changes in the new version.

Author(s): Steven Holzner
Edition: 1
Year: 2002

Language: English
Pages: 720

Main Page......Page 1
Table of content......Page 2
Copyright......Page 11
About the Author......Page 14
Acknowledgments......Page 15
We Want to Hear from You!......Page 16
Introduction......Page 17
Who Is This Book For?......Page 18
What's Inside?......Page 19
What Do You Need?......Page 21
Where to Download the Code for This Book......Page 22
Conventions Used in This Book......Page 23
A Note From the Author......Page 24
Week 1: At a Glance......Page 25
Day 1. Getting Started!......Page 26
What Are JavaServer Pages Good For?......Page 27
It All Starts with Java......Page 30
The Tomcat Server......Page 31
Creating Web Documents......Page 39
A Brief History of JSP......Page 42
Dissecting Our First JSP......Page 52
Overview of JSP Syntax......Page 54
Online JSP Resources......Page 60
Summary......Page 63
Q&A......Page 64
Workshop......Page 65
Day 2. Handling Data and Operators......Page 66
Java in JSP......Page 67
The JSP Programming Environment......Page 69
Handling Data in JSP......Page 73
Creating Variables......Page 75
Initializing Variables......Page 78
Data Types......Page 79
Converting Between Data Types......Page 81
Strings......Page 85
Creating Strings......Page 88
Strings Are Objects......Page 89
Determining String Length......Page 90
Creating and Working with Arrays......Page 93
Working with Operators......Page 98
Assignment Operators......Page 101
Incrementing and Decrementing Operators......Page 103
Multiplication and Division Operators......Page 105
Addition and Subtraction Operators......Page 107
Relational Operators......Page 109
Logical Operators......Page 111
Understanding Operator Precedence......Page 113
Summary......Page 116
Q&A......Page 117
Workshop......Page 118
Day 3. Branching, Looping, and Creating Methods......Page 119
Branching Statements......Page 121
Loops......Page 133
Creating Methods......Page 145
Summary......Page 159
Q&A......Page 160
Workshop......Page 161
Day 4. Reading Data from Web Pages: Buttons and Text Fields......Page 162
HTML Controls......Page 164
HTML Forms......Page 166
Submitting Forms......Page 170
Sending Data to the Server......Page 173
Using 'request' Objects......Page 175
Reading Data on the Server......Page 182
Using Text Fields......Page 184
Using Text Areas......Page 188
Using Password Controls......Page 192
Using Hidden Controls......Page 195
Using Buttons......Page 197
JSP to JSP—Navigating Directly to JSP Pages......Page 200
Using Multiple Forms......Page 203
Summary......Page 206
Q&A......Page 207
Workshop......Page 208
Day 5. Reading Data from Web Pages: Check Boxes, Radio Buttons, and Select Controls......Page 209
Using Check Boxes......Page 210
Using Radio Buttons......Page 213
Selecting and Deselecting Check Boxes and Radio Buttons in Code......Page 216
Using Select Controls......Page 220
Using Multiple-Selection Select Controls......Page 223
Check Box Groups......Page 226
Uploading Files......Page 229
Image Controls......Page 232
Using 'Creating Image Maps......Page 237
Using Named Targets......Page 241
Getting All Parameter Names......Page 244
Getting Request Header Information......Page 247
Reset Buttons......Page 249
Summary......Page 251
Q&A......Page 252
Workshop......Page 253
Day 6. Creating JSP Components: JavaBeans......Page 254
Creating a Java Class......Page 256
Creating a Constructor......Page 258
Creating a Method......Page 259
Compiling a Java Class......Page 260
Installing a Compiled Java Class......Page 261
Using a Compiled Java Class......Page 262
Creating a Package......Page 264
Using a Package......Page 266
Passing Data to a Constructor......Page 268
Using 'Creating a Read-Only Property......Page 273
'Creating a Read/Write Property......Page 277
'Creating Private Methods......Page 281
Java Utility Classes: Working with Dates......Page 284
Summary......Page 295
Q&A......Page 296
Workshop......Page 297
Day 7. Tracking Users with Sessions and Cookies......Page 298
Using Hidden Controls......Page 299
The Cookie Class......Page 303
The 'HttpServletResponse' Interface......Page 305
Creating a Cookie......Page 309
Reading a Cookie......Page 312
Setting and Reading a Cookie in the Same Page......Page 315
Using Sessions......Page 318
Creating a Session......Page 321
Setting Session Timeouts......Page 324
Using Applications......Page 325
Using Sessions, Applications, and JavaBeans......Page 328
Summary......Page 331
Q&A......Page 332
Workshop......Page 333
Week 2: At a Glance......Page 334
Day 8. Handling Errors......Page 335
Syntax Errors......Page 336
Runtime Errors......Page 340
Exceptions......Page 342
Using 'try/catch' Blocks......Page 344
Handling Specific Exception Types......Page 347
Catching Multiple Exceptions......Page 350
Nesting 'try/catch' Statements......Page 352
Throwing Exceptions Yourself......Page 354
Throwing Exceptions from Methods......Page 355
Creating a Custom Exception Object......Page 358
Printing to the Server Console......Page 361
Using Log Files......Page 364
Using JSP Error Pages......Page 366
Using JSP Error Pages: The 'exception' Object......Page 368
Using JSP Error Pages: 'request' Object Attributes......Page 370
Summary......Page 372
Q&A......Page 373
Workshop......Page 374
Day 9. Using Custom JSP Tags......Page 375
Tag Libraries......Page 377
The 'Request' Tag Library......Page 379
Tag Library Descriptor Files......Page 396
Creating a Simple Tag......Page 399
Summary......Page 406
Q&A......Page 407
Workshop......Page 408
Day 10. Creating Custom Tags......Page 409
A Simple Text-Inserting Tag......Page 410
Creating and Supporting Attributes in Custom Tags......Page 421
Iterating Tags......Page 425
Cooperating Tags......Page 430
Using Scripting Variables......Page 433
Summary......Page 438
Q&A......Page 439
Workshop......Page 440
Day 11. Creating More Powerful JavaBeans......Page 441
Why Inheritance?......Page 442
Using Inheritance......Page 443
Using Access Specifiers......Page 448
Calling Superclass Constructors......Page 452
Overloading Methods......Page 459
Overriding Methods......Page 461
Using Superclass Variables with Subclassed Objects......Page 464
Using Runtime Polymorphism......Page 467
Creating Abstract Classes......Page 471
Using Interfaces for Multiple Inheritance......Page 474
Summary......Page 478
Q&A......Page 479
Workshop......Page 480
Day 12. Creating Servlets......Page 481
Using 'Creating Java Servlets......Page 485
Using the 'response' Object......Page 494
Using the 'request' Object......Page 497
The Life Cycle of a Servlet......Page 501
Creating Web Applications with Servlets......Page 503
Using Servlet Configurations and Contexts......Page 507
Summary......Page 513
Q&A......Page 514
Workshop......Page 515
Day 13. Creating More Powerful Servlets......Page 516
Sessions and Servlet Contexts......Page 517
Forwarding Requests to Other Web Resources......Page 524
Including Output from Other Web Resources......Page 527
Handling Forwards and Includes......Page 530
JSP Model 1 Architecture......Page 533
JSP Model 2 Architecture......Page 534
Supporting User Authentication......Page 539
Using Cookies in Servlets......Page 545
Thread Safety......Page 547
Summary......Page 549
Q&A......Page 550
Workshop......Page 551
Day 14. Using Filters......Page 552
Understanding Filters......Page 553
Creating a Simple Filter......Page 554
Filtering JSP Pages......Page 560
Creating Filter Chains......Page 562
Using Initialization Parameters......Page 567
Inserting Text Into the Response......Page 573
Logging......Page 576
Using Filters for User Authentication......Page 580
Restricting Access......Page 584
Summary......Page 587
Q&A......Page 588
Workshop......Page 589
Week 3: At a Glance......Page 590
Day 15. Handling Files on the Server......Page 591
Using Tomcat Logging......Page 592
Using the 'File' Class......Page 595
Streams, Readers, and Writers......Page 600
Working with Text Files......Page 601
Writing Text Files......Page 605
Reading Text Files......Page 609
Working with Binary Files......Page 612
Writing Byte Data to Files......Page 616
Reading Byte Data from Files......Page 618
Writing Objects to Files......Page 620
Reading Objects from Files......Page 625
Summary......Page 628
Q&A......Page 629
Workshop......Page 630
Day 16. Getting Started with Databases......Page 631
What Are Databases?......Page 632
Java Database Connectivity......Page 634
JDBC Drivers......Page 638
Creating Connections......Page 643
Using Structured Query Language......Page 656
Summary......Page 662
Q&A......Page 663
Workshop......Page 664
Day 17. Working with Databases......Page 665
Data Lookup......Page 666
The 'ResultSet' Methods......Page 670
Navigating in a 'RecordSet'......Page 679
Setting Cursor Type......Page 683
Getting Information About a Result Set......Page 687
Joining Tables......Page 691
Creating and Filling Tables......Page 694
Updating Data......Page 698
Summary......Page 699
Q&A......Page 700
Workshop......Page 701
Day 18. Using XML and XSLT in JSP......Page 702
Handling XML with JSP......Page 703
Sending XML Data to the Browser......Page 708
Java and XML......Page 710
DOM XML Parsing......Page 711
SAX XML Parsing......Page 726
Handling XSLT with JSP......Page 736
Summary......Page 746
Q&A......Page 747
Workshop......Page 748
Day 19. Using Struts......Page 749
Putting Struts to Work......Page 750
Getting Struts......Page 753
Creating the View......Page 754
Creating Custom Tags to Supply Data......Page 766
Creating the Controller Adapter......Page 769
Accessing Data in the Results Page......Page 776
Creating the Model......Page 778
Summary......Page 781
Q&A......Page 782
Workshop......Page 783
Day 20. Creating Images on the Fly and Handling Internet Programming......Page 784
Creating an Image on the Fly......Page 785
Drawing in Response to User Actions......Page 801
Drawing Images......Page 805
Embedding Images in HTML Documents......Page 809
Internet Programming—Interacting Directly with Servers......Page 811
Creating Client/Server Applications......Page 817
Summary......Page 822
Q&A......Page 823
Workshop......Page 824
Day 21. Client-Side Programming and Deploying Your Projects......Page 825
Working with JavaScript......Page 826
Creating a 'Creating Variables......Page 836
JavaScript Operators......Page 838
Branching Statements......Page 844
JavaScript Loops......Page 845
JavaScript Functions......Page 847
Handling Events in JavaScript......Page 849
Deploying Your Web Applications......Page 857
Summary......Page 863
Q&A......Page 864
Workshop......Page 865
Appendixes At a Glance......Page 866
Appendix A. Answers to the Quiz Questions......Page 867
Quiz Answers for Day 1......Page 868
Quiz Answers for Day 2......Page 869
Quiz Answers for Day 3......Page 870
Quiz Answers for Day 4......Page 871
Quiz Answers for Day 5......Page 872
Quiz Answers for Day 6......Page 873
Quiz Answers for Day 7......Page 874
Quiz Answers for Day 8......Page 875
Quiz Answers for Day 9......Page 876
Quiz Answers for Day 10......Page 877
Quiz Answers for Day 11......Page 878
Quiz Answers for Day 12......Page 879
Quiz Answers for Day 13......Page 880
Quiz Answers for Day 14......Page 881
Quiz Answers for Day 15......Page 882
Quiz Answers for Day 16......Page 883
Quiz Answers for Day 17......Page 884
Quiz Answers for Day 18......Page 885
Quiz Answers for Day 19......Page 886
Quiz Answers for Day 20......Page 887
Quiz Answers for Day 21......Page 888
Index......Page 889
Index SYMBOL......Page 890
Index A......Page 891
Index B......Page 893
Index C......Page 895
Index D......Page 900
Index E......Page 903
Index F......Page 905
Index G......Page 907
Index H......Page 908
Index I......Page 909
Index J......Page 911
Index K......Page 914
Index L......Page 915
Index M......Page 921
Index N......Page 924
Index O......Page 925
Index P......Page 927
Index R......Page 929
Index S......Page 931
Index T......Page 936
Index U......Page 939
Index V......Page 940
Index W......Page 941
Index X......Page 943