JSP 2.0 - The Complete Reference
|
JSP: The Complete Reference
|
Instant Java Servlets
|
About
Key topics and downloads
Table of contents
Table of Contents
The Web Programming Environment
Chapter 1 - Evolution of the Web Application
Chapter 2 - Overview of Hypertext Transfer Protocol (HTTP)
Chapter 3 - Introduction to Servlets
Chapter 4 - JSP Overview
Elements of JSP
Chapter 5 - JSP Syntax and Semantics
Chapter 6 - Expressions, Scriptlets, and Declarations
Chapter 7 - Request Dispatching
Chapter 8 - Session and Thread Management
Chapter 9 - Application Event Listeners
Chapter 10 - Filters
JSP Tag Extensions
Chapter 11 - Introduction to Custom Tags
Chapter 12 - Expression Language
Chapter 13 - The JSP Standard Tag Library (JSTL)
Chapter 14 - JSP Fragments
JSP Application Development
Chapter 15 - Database Access with JDBC
Chapter 16 - JSP and XML
Chapter 17 - JSP Testing and Debugging
Chapter 18 - Deploying Web Applications
Chapter 19 - Case Study: A Product Support Center
Appendices
Appendix A - API Reference
Chapter 1 - Evolution of the Web Application
Birth of the Web
Growth of the Web Programming Model
The Shift from Client-Side to Server-Side Solutions
Chapter 2 - Overview of Hypertext Transfer Protocol (HTTP)
What Is HTTP?
A Language for Requesting Documents over the Internet
The HTTP Specification
HTTP Request Model
Connecting to the Web Server
Sending the HTTP Request
Server Acceptance of the Request
The HTTP Response from the Server
Examples
Nested Requests
Chapter 3 - Introduction to Servlets
Servlet Lifecycle
init
service
destroy
Example: Kilometers per Liter to Miles per Gallon Servlet
Servlet Classes
Servlet
Servlet Request
Generic Request
HTTP-Specific Request
Servlet Response
Generic Response
HTTP-Specific Response
Servlet Context
Threading Models
Default Threading Model
SingleThreadModel
HTTP Sessions
The HttpSession Interface
Chapter 4 - JSP Overview
How JSP Works
A Basic Example
Chapter 5 - JSP Syntax and Semantics
The JSP Development Model
Components of a JSP Page
Directives
The page Directive
language
extends
import
session
buffer and autoFlush
isThreadSafe
info
contentType and pageEncoding
errorPage and isErrorPage
The include Directive
The taglib Directive
Comments
Expressions
Scriptlets
Declarations
Implicit Objects
Standard Actions
Tag Extensions
A Complete Example
A Page Directive
A jsp:include Action
Scriptlet
JSP Expressions
A Declaration
Chapter 6 - Expressions, Scriptlets, and Declarations
Expressions
Scriptlets
Expression and Scriptlet Handling by the JSP Container
HTML Template Data and Expressions
Scriptlet Contents
Container-Generated Initialization and Exit Code
Implicit Objects and the JSP Environment
request
response
pageContext
session
application
out
config
page
exception
Initialization Parameters
Declarations
What Is a Declaration?
Where Declaration Code Is Generated
Primary Uses for Declarations
Variable Declarations
Thread Safety and Instance Variables
Method Definitions
Overriding jspInit and jspDestroy
Access to Implicit Objects
Inner Classes
Chapter 7 - Request Dispatching
Anatomy of Request Processing
Including Other Resources
The include Directive
How It Works
Effect of Changes in an Included File
Using the include Directive to Copy Source Code
The jsp:include Action
How It Works
Restrictions
Runtime Features
Passing Parameters to the Included JSP
Retrieving the Original URI
Which Method to Use
Forwarding Requests
The RequestDispatcher Object
Request Dispatching vs. Redirection
Model 1 vs. Model 2
Chapter 8 - Session and Thread Management
Session Tracking
Hidden Fields
URL Rewriting
Cookies
The Session API
Creating Sessions
Joining a Session
Session Tracking Mechanisms
Storing and Retrieving Objects from Sessions
Destroying Sessions
Examples Revisited
Hidden Fields Example
URL Rewriting Example - The Page Counter
Cookies Example - Language Preference
Session Binding Listeners
Thread Management
Threading Concepts
Creating Threads by Subclassing java.lang.Thread
Creating Threads by Implementing Runnable
Creating Threads with Timer and TimerTask
Synchronizing Threads
Servlet Threading Models
Default Threading Model
Single-Threaded Model
Multithreaded Applications
Long-Running Requests with Status Messages
Application Considerations
Chapter 9 - Application Event Listeners
Beyond Session Binding Listeners
Event Scope
Event Listener Interfaces
How It Works
Listeners for Lifecycle Events
ServletContextListener
HttpSessionListener
ServletRequestListener
HttpSessionActivationListener
HttpSessionBindingListener
Listeners for Attribute Change Events
ServletContextAttributeListener
HttpSessionAttributeListener
ServletRequestAttributeListener
Examples of Application Event Listeners
Currency Exchange Rate Cache
Session Log
Controlling an Expensive Shared Resource
Chapter 10 - Filters
Filter Overview
The Filter Lifecycle
A Simple Example
Developing and Deploying a Filter
The Filter API
javax.servlet.Filter
javax.servlet.FilterChain
javax.servlet.FilterConfig
Servlet Request and Response Wrappers
Configuring a Filter
A Request Filter Example
A Response Filter Example
Chapter 11 - Introduction to Custom Tags
Why Custom Tags?
Developing Your First Custom Tag
Step 1 - Define the Tag
Step 2 - Create the TLD Entry
Step 3 - Write the Tag Handler
Compiling the Sample Code
Step 4 - Incorporate the Tag Into a JSP Page
The taglib Directive
How to Use the Tag in the JSP Page
How Tag Handlers Work
What the JSP Container Does
Tag-Related Code Generated by the Container
What a Tag Handler Does
Tag Libraries
The Tag Library Descriptor (TLD)
TLD Elements
The taglib Directive
Mapping Tag Libraries in the web.xml File
The Tag Handler API
The Tag Interface
The TagSupport Class
The Tag Handler Life Cycle
The Flowchart
An Example of Generated Code
Defining Tag Attributes
The IterationTag Interface
The Body Tag Handler API
Body Content
The BodyTag Interface
The BodyTagSupport Class
Chapter 12 - Expression Language
What Is EL?
EL Syntax
Literals and Variables
Implicit Objects
Extracting Property Values
Operators
Arithmetic
Relational
Logical
Empty
Functions
Function Implementation Class
Registering the Function
Invoking the Custom Function
Chapter 13 - The JSP Standard Tag Library (JSTL)
Getting Started with JSTL
Using JSTL in a JSP Page
Core Tags
General-Purpose Actions
c:out
c:set
c:remove
c:catch
Conditional and Iterator Actions
c:if
c:choose
c:when
c:otherwise
c:forEach
c:forTokens
Networking Tags
c:import
c:url
c:redirect
c:param
Example
XML Tags
Core Actions
x:parse
x:out
x:set
Flow Control Actions
x:if
x:choose
x:when
x:otherwise
x:forEach
Transform Actions
x:transform
x:param
Example
SQL Tags
Data Extraction and Manipulation Tags
sql:query
sql:update
DataSource Tags
sql:transaction
sql:setDataSource
sql:param
sql:dateParam
Example
Formatting Tags
Internationalization (i18n) Actions
fmt:setLocale
fmt:bundle
fmt:setBundle
fmt:message
fmt:param
fmt:requestEncoding
Date and Number Formatting Actions
fmt:timeZone
fmt:setTimeZone
fmt:formatNumber
fmt:parseNumber
fmt:formatDate
fmt:parseDate
Chapter 14 - JSP Fragments
JSP Fragments
Fragments Used as Tag Bodies
Fragments Used as Attribute Values
The SimpleTag Interface
SimpleTag Lifecycle
SimpleTag Interface Example
Tag Files
Tag File Configuration and Usage
Tag File Example
Chapter 15 - Database Access with JDBC
Overview of JDBC
JDBC API Versions
Basic JDBC Operations
Essential JDBC Classes
A Simple JDBC Example
JDBC Drivers
Driver Types
The JDBC-ODBC Bridge
Registering a Driver
Automatic Registration
Creating a Driver Instance
Using the jdbc.drivers System Property
Direct Registration
Using a JNDI DataSource
Connecting to a Database with DriverManager
The JDBC Database URL
Connecting to a Database
The Statement Interfaces
Statement
The executeQuery Method
The executeUpdate Method
The execute Method
The executeBatch Method
PreparedStatement
Using Prepared Statements to Avoid Dynamic Syntax Errors
CallableStatement
Stored Procedures in Microsoft Access
Result Sets
Scrollable Result Sets
Updatable Result Sets
RowSets
Using Metadata
Database Metadata
ResultSetMetadata
New Features in JDBC 2.0 and Beyond
Chapter 16 - JSP and XML
XML Overview
The Problem XML Solves
XML Syntax
The Document Type Definition
XML Schema
Elements of an XML Schema
An XML Schema Example
XML Processing Models
Document Object Model (DOM)
Node Interfaces
Node Collection Interfaces
Node Metadata
Exceptions
Simple API for XML (SAX)
The SAX Parser
Handlers
Parsing XML
JAXP
Parsing with DOM
Parsing with SAX
SAX 2.0
XSL Transformations with XSLT
XSLT in Action
JAXP Again
An XSLT Filter
XML Syntax for JSP
Chapter 17 - JSP Testing and Debugging
Building a Mental Model
Translation and Compilation
Testing in Isolation
Debugging Tools
Capturing Form Parameters
A Debugging Web Client
Tracing HTTP Requests
Chapter 18 - Deploying Web Applications
The Web Application Environment
Directory Structure
Resource Mapping
The Servlet Context
The Web Archive (war) File
The Deployment Descriptor - web.xml
Sample Deployment Descriptor
Chapter 19 - Case Study: A Product Support Center
Process Flow
Data Model
Developing the System
Model-View-Controller Architecture
Model Classes
Business Objects
Customer Class
Product Class
CustomerProduct Class
Employee Class
Problem Class
ProblemLog Class
Event Class
Application Objects
Model Class
WebModel Class
Using the Model
View Classes
Support Pages
SetBaseURL.jsp
Banner.jsp
ErrorPage.jsp
JSP View Pages
Customers.jsp
CustomersList.jsp
Customer.jsp
Problem.jsp
Confirm.jsp
Products.jsp
ProductsList.jsp
ProductProblems.jsp
Problems.jsp
Controller Classes
The Action Base Class
The Controller Servlet
Action Classes
CustomersSearchAction Class
CustomersListSelectAction Class
CustomerNewProblemAction Class
ProductsSearchAction Class
ProductsListSelectAction Class
ProblemsSelectAction Class
ProblemSubmitAction Class
Appendix A - API Reference
javax.servlet package
javax.servlet.http package
javax.servlet.jsp package
javax.servlet.jsp.el package
javax.servlet.jsp.tagext package