did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780596005726

Java Servlet and Jsp Cookbook

by
  • ISBN13:

    9780596005726

  • ISBN10:

    0596005725

  • Format: Paperback
  • Copyright: 2004-01-01
  • Publisher: Oreilly & Associates Inc
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $49.99 Save up to $5.00
  • Buy New
    $48.49
    Add to Cart Free Shipping Icon Free Shipping

    USUALLY SHIPS IN 2-3 BUSINESS DAYS

Supplemental Materials

What is included with this book?

Summary

Rather than focus on theory and concept, this new addition to our Cookbook line presents scores of real- world problems, and provides concise, practical solutions to each. With literally hundreds of examples and thousands of lines of code, any Java web developer who uses JavaServer Pages or servlets, even casually, will find useful tips and techniques in this book, as well as full-fledged solutions to significant web application development problems. The Java Servlet & JSP Cookbook lets developers put theory from other API-focused books into practice.

Author Biography

Bruce W. Perry is a independent Java software developer and writer

Table of Contents

Prefacep. xiii
Writing Servlets and JSPsp. 1
Writing a Servletp. 1
Writing a JSPp. 7
Compiling a Servletp. 10
Packaging Servlets and JSPsp. 11
Creating the Deployment Descriptorp. 14
Deploying Servlets and JSPsp. 17
Deploying an Individual Servlet on Tomcatp. 17
Using a Context Element in Tomcat's server.xmlp. 22
Deploying an Individual Servlet on WebLogicp. 24
Deploying an Individual JSP on Tomcatp. 29
Deploying an Individual JSP on WebLogicp. 30
Deploying a Web Application on Tomcatp. 31
Deploying a Web Application on WebLogic Using Antp. 37
Using the WebLogic Administration Consolep. 39
Using WebLogic Builder to Deploy a Web Applicationp. 43
Using the weblogic.Deployer Command-Line Toolp. 46
Naming Your Servletsp. 49
Mapping a Servlet to a Name in web.xmlp. 50
Creating More Than One Mapping to a Servletp. 52
Creating a JSP-Type URL for a Servletp. 54
Mapping Static Content to a Servletp. 55
Invoking a Servlet Without a web.xml Mappingp. 57
Mapping All Requests Within a Web Application to a Servletp. 59
Mapping Requests to a Controller and Preserving Servlet Mappingsp. 61
Creating Welcome Files for a Web Applicationp. 65
Restricting Requests for Certain Servletsp. 66
Giving Only the Controller Access to Certain Servletsp. 71
Using Apache Antp. 74
Obtaining and Setting Up Antp. 74
Using Ant Targetsp. 76
Including Tomcat JAR files in the Build File Classpathp. 80
Compiling a Servlet with an Ant Build Filep. 83
Creating a WAR File with Antp. 86
Creating a JAR File with Antp. 89
Starting a Tomcat Application with Antp. 92
Stopping a Tomcat Application with Antp. 95
Altering the Format of JSPsp. 98
Precompiling a JSP in Tomcatp. 99
Precompiling a JSP in WebLogicp. 102
Precompiling JSPs with the Precompilation Protocolp. 104
Mapping a JSP to Its Page Implementation Classp. 105
Creating a JSP from Scratch as a JSP Documentp. 106
Generating an XML View from a JSPp. 110
Dynamically Including Content in Servlets and JSPsp. 119
Including a Resource Each Time a Servlet Handles a Requestp. 120
Using an External Configuration to Include a Resource in a Servletp. 122
Including Resources Nested at Multiple Levels in a Servletp. 125
Including a Resource that Seldom Changes into a JSPp. 130
Including Content in a JSP Each Time the JSP Handles a Requestp. 133
Using an External Configuration File to Include a Resource in a JSPp. 137
Including an XML Fragment in a JSP Documentp. 141
Including Content from Outside a Context in a JSPp. 144
Handling Web Form Data in Servlets and JSPsp. 148
Handling a POST HTTP Request in a Servletp. 149
Handling a POST HTTP Request in a JSPp. 153
Setting the Properties of a JavaBean in a JSPp. 155
Setting a Scoped Attribute in a JSP to the Value of a Form Parameterp. 158
Posting Data from a Servletp. 161
Posting Data from a JSPp. 164
Using a Servlet to Add a Parameter to a Query Stringp. 168
Using a JSP to Add a Parameter to a Query Stringp. 170
Using a Filter to Read Parameter Valuesp. 171
Uploading Filesp. 174
Preparing the HTML Page for File Uploadsp. 175
Using the com.oreilly.servlet Libraryp. 177
Uploading One File at a Timep. 178
Uploading Multiple Filesp. 181
Renaming Filesp. 185
Using a JSP to Handle a File Uploadp. 187
Handling Exceptions in Web Applicationsp. 192
Declaring Exception Handlers in web.xmlp. 192
Creating an Exception-Handling Servletp. 196
Sending an Error from a Servletp. 199
Sending an Error from a JSPp. 201
Creating an Error-Handling JSPp. 202
Declaring a Special Exception-Handling JSP for Other JSPsp. 205
Reading and Setting Cookiesp. 209
Setting a Cookie with a Servletp. 211
Creating an Array from All of the Request's Cookiesp. 214
Setting a Cookie with a JSPp. 215
Reading Cookie Values with a Servletp. 220
Reading Cookie Values with a JSPp. 222
Altering or Removing a Cookie That Has Already Been Setp. 225
Session Trackingp. 227
Setting the Session Timeout in web.xmlp. 228
Setting the Session Timeout in All Tomcat Web Applicationsp. 231
Setting the Session Timeout Programmaticallyp. 233
Checking if a Session Exists in an HttpServletRequestp. 235
Tracking Session Activity in Servletsp. 237
Tracking Session Activity in JSPsp. 240
Using URL Rewriting in a JSPp. 244
Using URL Rewriting in a Servletp. 247
Using a Listener to Track the Session Lifecyclep. 251
Using a Listener to Monitor Session Attributesp. 254
Using a Filter to Monitor Session Attributesp. 258
Integrating JavaScript with Servlets and JSPsp. 263
Including JavaScript Modules in a Servletp. 263
Including JavaScript Modules in a JSPp. 267
Creating a New Window with JavaScript in a Servletp. 269
Creating a New Window with JavaScript in a JSPp. 272
Using JavaScript to Validate Form Values in a Servletp. 274
Using JavaScript to Validate Form Values in a JSPp. 277
Sending Non-HTML Contentp. 279
Sending a PDF Filep. 280
Sending a Word Processing Filep. 284
Sending an XML filep. 286
Sending an Audio Filep. 289
Viewing Internal Resources in a Servletp. 292
Logging Messages from Servlets and JSPsp. 296
Logging Without Log4jp. 298
Setting Up Log4jp. 300
Using a Logger Without a Configuration Filep. 301
Adding an Appender to the Root Loggerp. 304
Using a Pattern with a Logger's Appenderp. 306
Using log4j in a JSPp. 310
Logging Messages Using a Servlet Context Event Listenerp. 316
Logging Messages Using a Session Event Listenerp. 320
Authenticating Clientsp. 324
Creating Users and Passwords with Tomcatp. 324
Setting Up SSL on Tomcatp. 325
Using BASIC Authenticationp. 328
Using Form-Based Authenticationp. 331
Logging Out a Userp. 335
Using JAAS to Create a LoginModulep. 337
Creating the JAAS Configuration Filep. 344
Using JAAS in a Servletp. 346
Using JAAS in a JSPp. 349
Binding, Accessing, and Removing Attributes in Web Applicationsp. 354
Setting ServletContext Attributes in Servletsp. 354
Setting ServletContext Attributes in JSPsp. 357
Accessing or Removing ServletContext Attributes in Servletsp. 360
Accessing or Removing ServletContext Attributes in JSPsp. 362
Setting Session Attributes in Servletsp. 364
Setting Session Attributes in JSPsp. 366
Accessing or Removing Session Attributes in Servletsp. 368
Accessing or Removing Session Attributes in JSPsp. 369
Setting Request Attributes in Servletsp. 371
Setting Request Attributes in JSPsp. 373
Accessing or Removing Request Attributes in Servletsp. 375
Accessing or Removing Request Attributes in JSPsp. 376
Embedding Multimedia in JSPsp. 379
Embedding an Applet in a JSP Using jsp:pluginp. 379
Embedding an Applet in a JSP Using the HTML Converterp. 382
Automatically Creating HTML Template for Including Flash Filesp. 386
Writing HTML Template to Embed a Flash Filep. 388
Embedding Flash in a Servletp. 390
Embedding a QuickTime Movie in a JSPp. 392
Embedding an SVG File in a JSPp. 394
Embedding a Background Soundtrack in a JSPp. 396
Working With the Client Requestp. 398
Examining HTTP Request Headers in a Servletp. 398
Examining HTTP Request Headers in a JSPp. 400
Using a Filter to Alter Request Headersp. 402
Automatically Refreshing a Servletp. 405
Automatically Refreshing a JSPp. 407
Counting the Number of Web Application Requestsp. 408
Filtering Requests and Responsesp. 411
Mapping a Filter to a Servletp. 412
Mapping a Filter to a JSPp. 415
Mapping More Than One Filter to a Servletp. 416
Changing the Order in Which Filters are Applied to Servletsp. 418
Configuring Initialization Parameters for a Filterp. 419
Optionally Blocking a Request with a Filterp. 422
Filtering the HTTP Responsep. 424
Using Filters with RequestDispatcher Objectsp. 427
Checking Form Parameters with a Filterp. 429
Blocking IP Addresses with a Filterp. 434
Managing Email in Servlets and JSPsp. 439
Placing the Email-Related Classes on your Classpathp. 439
Sending Email from a Servletp. 441
Sending Email from a Servlet Using a JavaBeanp. 444
Accessing Email from a Servletp. 449
Accessing Email from a Servlet Using a JavaBeanp. 454
Handling Attachments from an Email Received in a Servletp. 455
Adding Attachments to an Email in a Servletp. 461
Reading a Received Email's Headers from a Servletp. 466
Accessing Databasesp. 471
Accessing a Database from a Servlet Without DataSourcep. 472
Configuring a DataSource in Tomcatp. 475
Using a DataSource in a Servlet with Tomcatp. 478
Creating a DataSource on WebLogicp. 481
Using a JNDI Lookup to get a DataSource from WebLogicp. 484
Using a DataSource from WebLogic in a JSPp. 488
Calling a Stored Procedure from a Servletp. 490
Calling a Stored Procedure from a JSPp. 495
Converting a ResultSet to a Result Objectp. 500
Executing Several SQL Statements Within a Single Transactionp. 505
Using Transactions with JSPsp. 511
Finding Information about a ResultSetp. 513
Using Custom Tag Librariesp. 519
Creating a Classic Tag Handlerp. 520
Creating a JSP 1.2 TLD for a Classic Tag Handlerp. 524
Creating a JSP 2.0 TLD for a Classic Tag Handlerp. 526
Packaging a Tag Library in a Web Applicationp. 529
Packaging the Tag Library in a JAR Filep. 530
Using the Custom Tag in a JSPp. 532
Handling Exceptions in a Custom Tag Classp. 533
Creating a Simple Tag Handlerp. 536
Creating a TLD for a Simple Tag Handlerp. 539
Using a Simple Tag Handler in a JSPp. 541
Creating a JSP Tag Filep. 543
Packaging the JSP Tag File in a Web Applicationp. 545
Packaging the JSP Tag File in a JARp. 546
Using a Custom Tag Associated with a Tag Filep. 547
Adding a Listener Class to a Tag Libraryp. 548
Using the JSTLp. 551
Downloading the JSTL 1.0 and Using the JSTL Tags in JSPsp. 552
Downloading the Java Web Services Developer Packp. 554
Using the Core JSTL Tagsp. 555
Using the XML Core JSTL Tagsp. 558
Using the XML Transform Tagsp. 561
Using the Formatting JSTL Tagsp. 564
Using A SQL JSTL Tag with a DataSource Configurationp. 567
Using A SQL JSTL Tag Without a DataSource Configurationp. 570
Accessing Scoped Variables with the ELp. 572
Accessing Request Parameters with the ELp. 574
Using the EL to Access Request Headersp. 576
Using the EL to Access One Request Headerp. 577
Accessing Cookies with the ELp. 579
Using the EL to Access JavaBean Propertiesp. 580
Using JSTL Functionsp. 585
Internationalizationp. 590
Detecting the Client Locale in a Servletp. 591
Detecting the Client's Locales in a JSPp. 594
Creating a ResourceBundle as a Properties Filep. 596
Creating a ResourceBundle as a Java Classp. 597
Using the ResourceBundle in a Servletp. 599
Using the ResourceBundle in a JSPp. 602
Formatting Dates in a Servletp. 603
Formatting Dates in a JSPp. 605
Formatting Currencies in a Servletp. 607
Formatting Currencies in a JSPp. 609
Formatting Percentages in a Servletp. 610
Formatting Percentages in a JSPp. 612
Setting the Localization Context in the Deployment Descriptorp. 613
Using JNDI and Enterprise JavaBeansp. 615
Configuring a JNDI Object in Tomcatp. 616
Accessing the Tomcat JNDI Resource from a Servletp. 619
Accessing the Tomcat JNDI Resource from a JSPp. 625
Configuring a JNDI Resource in WebLogicp. 628
Viewing the JNDI Tree in WebLogicp. 630
Accessing the WebLogic JNDI Resource from a Servletp. 631
Accessing the WebLogic JNDI Resource from a JSPp. 635
Accessing an EJB Using the WebLogic JNDI Treep. 638
Harvesting Web Informationp. 647
Parsing an HTML Page Using the javax.swing.text Subpackagesp. 648
Using a Servlet to Harvest Web Datap. 651
Creating a JavaBean as a Web Page Parserp. 656
Using the Web Page Parsing JavaBean in a Servletp. 659
Using the Web Page Parsing JavaBean in a JSPp. 661
Using the Google and Amazon Web APIsp. 664
Getting Set Up with Google's Web APIp. 666
Creating a JavaBean to Connect with Googlep. 667
Using a Servlet to Connect with Googlep. 671
Using a JSP to Connect with Googlep. 675
Getting Set Up with Amazon's Web Services APIp. 677
Creating a JavaBean to Connect with Amazonp. 679
Using a Servlet to Connect with Amazonp. 684
Using a JSP to Connect with Amazonp. 688
Indexp. 691
Table of Contents provided by Ingram. All Rights Reserved.

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program