10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Contents<br />

6<br />

4 <strong>Java</strong> ServletTechnology .....................................................................................................................99<br />

What Is a Servlet? ................................................................................................................................. 99<br />

<strong>The</strong> Example Servlets ........................................................................................................................ 100<br />

Troubleshooting Duke's Bookstore Database Problems ....................................................... 102<br />

Servlet Life Cycle ................................................................................................................................ 102<br />

Handling Servlet Life-Cycle Events ......................................................................................... 103<br />

Handling Servlet Errors ............................................................................................................. 105<br />

Sharing Information ......................................................................................................................... 105<br />

Using Scope Objects .................................................................................................................. 105<br />

Controlling Concurrent Access to Shared Resources ........................................................... 106<br />

Accessing Databases .................................................................................................................. 107<br />

Initializing a Servlet ........................................................................................................................... 109<br />

Writing Service Methods .................................................................................................................. 110<br />

Getting Information from Requests ........................................................................................ 110<br />

Constructing Responses ............................................................................................................ 112<br />

Filtering Requests and Responses .................................................................................................... 114<br />

Programming Filters .................................................................................................................. 115<br />

Programming Customized Requests and Responses ............................................................ 117<br />

Specifying Filter Mappings ....................................................................................................... 119<br />

Invoking Other Web Resources ....................................................................................................... 122<br />

Including Other Resources in the Response ........................................................................... 122<br />

Transferring Control to Another Web Component .............................................................. 124<br />

Accessing the Web Context .............................................................................................................. 124<br />

Maintaining Client State ................................................................................................................... 125<br />

Accessing a Session .................................................................................................................... 125<br />

Associating Objects with a Session .......................................................................................... 126<br />

Session Management ................................................................................................................. 126<br />

Session Tracking ........................................................................................................................ 127<br />

Finalizing a Servlet ............................................................................................................................. 128<br />

Tracking Service Requests ........................................................................................................ 129<br />

Notifying Methods to Shut Down ............................................................................................ 129<br />

Creating Polite Long-Running Methods ................................................................................. 130<br />

Further Information about <strong>Java</strong> Servlet Technology .................................................................... 131<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!