Who Should Use This Tutorial
How to Read This Tutorial
About the Examples
Prerequisites for the Examples
How to Print This Tutorial
Typographical Conventions
The Role of XML and the Java Platform
What Is XML?
What Makes XML Portable?
Overview of the Java APIs for XML
JAXP
The SAX API
The DOM API
The XSLT API
JAXB
JAXB Binding Process
Validation
Representing XML Content
Customizing JAXB Bindings
Example
JAX-RPC
Overview of JAX-RPC
Using JAX-RPC
Creating a Web Service
Coding a Client
Invoking a Remote Method
SAAJ
Getting a Connection
Creating a Message
Populating a Message
Sending a Message
JAXR
Using JAXR
Sample Scenario
Scenario
Conclusion
Interactive Web Application Architectures
Java Servlet Technology
JavaServer Pages Technology
JavaServer Pages Standard Tag Library
JavaServer Faces Technology
Setting Up
Getting the Example Code
Setting the PATH Variable
Modifying the Build Properties File
Running the Application
Creating a Simple Web Application
Creating the JavaBeans Component
Creating a Web Client
Creating the Build Properties File
Creating the Build File
Creating the Deployment Descriptor
Building the Example Application
Installing the Web Application
Running the Getting Started Application
Modifying the Application
Modifying a JavaBeans Component
Modifying the Web Client
Common Problems and Their Solutions
Errors Starting Tomcat
Compilation Errors
Installation and Deployment Errors
Web Application Life Cycle
Web Applications
Packaging Web Applications
Installing Web Applications
Deploying Web Applications
Listing Installed and Deployed Web Applications
Running Web Applications
Configuring Web Applications
Prolog
Mapping URLs to Web Components
Declaring Welcome Files
Setting Initialization Parameters
Specifying Error Mappings
Declaring References to Environment Entries, Resource Environment Entries, or Resources
Updating Web Applications
Reloading Web Applications
Redeploying Web Applications
Removing Web Applications
Undeploying Web Applications
Duke's Bookstore Examples
Accessing Databases from Web Applications
Installing and Starting the PointBase Database Server
Populating the Example Database
Defining a Data Source in Tomcat
Configuring the Web Application to Reference a Resource
Mapping the Web Application Resource Reference to a Data Source
Further Information
Introduction to XML
What Is XML?
Why Is XML Important?
How Can You Use XML?
XML and Related Specs: Digesting the Alphabet Soup
Basic Standards
Schema Standards
Linking and Presentation Standards
Knowledge Standards
Standards That Build on XML
Summary
Generating XML Data
Writing a Simple XML File
Defining the Root Element
Writing Processing Instructions
Introducing an Error
Substituting and Inserting Text
Creating a Document Type Definition
Documents and Data
Defining Attributes and Entities in the DTD
Referencing Binary Entities
Defining Parameter Entities and Conditional Sections
Resolving A Naming Conflict
Using Namespaces
Designing an XML Data Structure
Saving Yourself Some Work
Attributes and Elements
Normalizing Data
Normalizing DTDs
Summary
The JAXP APIs
An Overview of the Packages
The Simple API for XML (SAX) APIs
The SAX Packages
The Document Object Model (DOM) APIs
The DOM Packages
The XML Stylesheet Language for Transformation (XSLT) APIs
The XSLT Packages
Compiling and Running the Programs
Where Do You Go from Here?
When to Use SAX
Echoing an XML File with the SAX Parser
Creating the Skeleton
Importing Classes
Setting up for I/O
Implementing the ContentHandler Interface
Setting up the Parser
Writing the Output
Spacing the Output
Handling Content Events
Compiling and Running the Program
Checking the Output
Identifying the Events
Compressing the Output
Inspecting the Output
Documents and Data
Adding Additional Event Handlers
Identifying the Document's Location
Handling Processing Instructions
Summary
Handling Errors with the Nonvalidating Parser
Displaying Special Characters and CDATA
Handling Special Characters
Handling Text with XML-Style Syntax
Handling CDATA and Other Characters
Parsing with a DTD
DTD's Effect on the Nonvalidating Parser
Tracking Ignorable Whitespace
Cleanup
Empty Elements, Revisited
Echoing Entity References
Echoing the External Entity
Summarizing Entities
Choosing your Parser Implementation
Using the Validating Parser
Configuring the Factory
Validating with XML Schema
Experimenting with Validation Errors
Error Handling in the Validating Parser
Parsing a Parameterized DTD
DTD Warnings
Handling Lexical Events
How the LexicalHandler Works
Working with a LexicalHandler
Using the DTDHandler and EntityResolver
The DTDHandler API
The EntityResolver API
Further Information
When to Use DOM
Documents Versus Data
Mixed Content Model
A Simpler Model
Increasing the Complexity
Choosing Your Model
Reading XML Data into a DOM
Creating the Program
Additional Information
Looking Ahead
Displaying a DOM Hierarchy
Echoing Tree Nodes
Convert DomEcho to a GUI App
Create Adapters to Display the DOM in a JTree
Finishing Up
Examining the Structure of a DOM
Displaying A Simple Tree
Displaying a More Complex Tree
Finishing Up
Constructing a User-Friendly JTree from a DOM
Compressing the Tree View
Acting on Tree Selections
Handling Modifications
Finishing Up
Creating and Manipulating a DOM
Obtaining a DOM from the Factory
Normalizing the DOM
Other Operations
Finishing Up
Validating with XML Schema
Overview of the Validation Process
Configuring the DocumentBuilder Factory
Validating with Multiple Namespaces
Further Information
Introducing XSLT and XPath
The JAXP Transformation Packages
How XPath Works
XPATH Expressions
The XSLT/XPath Data Model
Templates and Contexts
Basic XPath Addressing
Basic XPath Expressions
Combining Index Addresses
Wildcards
Extended-Path Addressing
XPath Data Types and Operators
String-Value of an Element
XPath Functions
Summary
Writing Out a DOM as an XML File
Reading the XML
Creating a Transformer
Writing the XML
Writing Out a Subtree of the DOM
Summary
Generating XML from an Arbitrary Data Structure
Creating a Simple File
Creating a Simple Parser
Modifying the Parser to Generate SAX Events
Using the Parser as a SAXSource
Doing the Conversion
Transforming XML Data with XSLT
Defining a Simple <article> Document Type
Creating a Test Document
Writing an XSLT Transform
Processing the Basic Structure Elements
Writing the Basic Program
Trimming the Whitespace
Processing the Remaining Structure Elements
Process Inline (Content) Elements
Printing the HTML
What Else Can XSLT Do?
Transforming from the Command Line with Xalan
Concatenating Transformations with a Filter Chain
Writing the Program
Understanding How the Filter Chain Works
Testing the Program
Conclusion
Further Information
JAXB Architecture
Architectural Overview
The JAXB Binding Process
JAXB Binding Framework
More About javax.xml.bind
More About Unmarshalling
More About Marshalling
More About Validation
XML Schemas
Representing XML Content
Binding XML Names to Java Identifiers
Java Representation of XML Schema
Binding XML Schemas
Simple Type Definitions
Default Data Type Bindings
Default Binding Rules Summary
Customizing JAXB Bindings
Scope
Scope Inheritance
What is Not Supported
JAXB APIs and Tools
General Usage Instructions
Description
Using the Examples
Configuring and Running the Examples Manually
Configuring and Running the Samples With Ant
JAXB Compiler Options
About the Schema-to-Java Bindings
Schema-Derived JAXB Classes
Basic Examples
Unmarshal Read Example
Modify Marshal Example
Create Marshal Example
Unmarshal Validate Example
Validate-On-Demand Example
Customizing JAXB Bindings
Why Customize?
Customization Overview
Customize Inline Example
Datatype Converter Example
External Customize Example
Fix Collides Example
Bind Choice Example
Types Supported By JAX-RPC
J2SE SDK Classes
Primitives
Arrays
Value Types
JavaBeans Components
Setting the Port
Creating a Web Service with JAX-RPC
Coding the Service Endpoint Interface and Implementation Class
Building the Service
Deploying the Service
Creating Web Service Clients with JAX-RPC
Static Stub Client Example
Dynamic Proxy Client Example
Dynamic Invocation Interface (DII) Client Example
More JAX-RPC Client Examples
Web Services Interoperability (WS-I) and JAX-RPC
Advanced JAX-RPC Examples
SOAP Message Handlers Example
Advanced Static Stub Example
Advanced Dynamic Proxy Example
Advanced DII Client Example
Further Information
Overview of SAAJ
Messages
Connections
Tutorial
Creating and Sending a Simple Message
Adding Content to the Header
Adding Content to the SOAP Body
Adding Content to the SOAPPart Object
Adding a Document to the SOAP Body
Manipulating Message Content Using SAAJ or DOM APIs
Adding Attachments
Adding Attributes
Using SOAP Faults
Code Examples
Request.java
MyUddiPing.java
HeaderExample.java
DOMExample.java and DomSrcExample.java
Attachments.java
SOAPFaultTest.java
Further Information
Overview of JAXR
What Is a Registry?
What Is JAXR?
JAXR Architecture
Implementing a JAXR Client
Establishing a Connection
Querying a Registry
Managing Registry Data
Using Taxonomies in JAXR Clients
Running the Client Examples
Before You Compile the Examples
Compiling the Examples
Running the Examples
Further Information
What is a Servlet?
The Example Servlets
Troubleshooting
Servlet Life Cycle
Handling Servlet Life Cycle Events
Handling Errors
Sharing Information
Using Scope Objects
Controlling Concurrent Access to Shared Resources
Accessing Databases
Initializing a Servlet
Writing Service Methods
Getting Information from Requests
Constructing Responses
Filtering Requests and Responses
Programming Filters
Programming Customized Requests and Responses
Specifying Filter Mappings
Invoking Other Web Resources
Including Other Resources in the Response
Transferring Control to Another Web Component
Accessing the Web Context
Maintaining Client State
Accessing a Session
Associating Attributes with a Session
Session Management
Session Tracking
Finalizing a Servlet
Tracking Service Requests
Notifying Methods to Shut Down
Creating Polite Long-Running Methods
Further Information
What Is a JSP Page?
Example
The Example JSP Pages
The Life Cycle of a JSP Page
Translation and Compilation
Execution
Creating Static Content
Response and Page Encoding
Creating Dynamic Content
Using Objects within JSP Pages
Expression Language
Deactivating Expression Evaluation
Using Expressions
Variables
Implicit Objects
Literals
Operators
Reserved Words
Examples
Functions
JavaBeans Components
JavaBeans Component Design Conventions
Creating and Using a JavaBeans Component
Setting JavaBeans Component Properties
Retrieving JavaBeans Component Properties
Using Custom Tags
Declaring Tag Libraries
Including the Tag Library Implementation
Reusing Content in JSP Pages
Transferring Control to Another Web Component
jsp:param Element
Including an Applet
Setting Properties for Groups of JSP Pages
Further Information
The Example JSP Pages
Using JSTL
Tag Collaboration
Core Tags
Variable Support Tags
Flow Control Tags
URL Tags
Miscellaneous Tags
XML Tags
Core Tags
Flow Control Tags
Transformation Tags
Internationalization Tags
Setting the Locale
Messaging Tags
Formatting Tags
SQL Tags
query Tag Result Interface
Functions
Further Information
What Is a Custom Tag?
The Example JSP Pages
Types of Tags
Tags with Attributes
Tags with Bodies
Tags That Define Variables
Communication Between Tags
Encapsulating Reusable Content using Tag Files
Tag File Location
Tag File Directives
Evaluating Fragments Passed to Tag Files
Examples
Tag Library Descriptors
Declaring Tag Files
Declaring Tag Handlers
Declaring Tag Attributes for Tag Handlers
Declaring Tag Variables for Tag Handlers
Programming Simple Tag Handlers
Basic Tags
Tags with Attributes
Tags with Bodies
Tags That Define Variables
Cooperating Tags
Examples
The Example JSP Pages
Using Scripting
Disabling Scripting
Declarations
Initializing and Finalizing a JSP Page
Scriptlets
Expressions
Programming Tags That Accept Scripting Elements
TLD Elements
Tag Handlers
Tags with Bodies
Cooperating Tags
Tags That Define Variables
JavaServer Faces Technology Benefits
What is a JavaServer Faces Application?
Framework Roles
A Simple JavaServer Faces Application
Steps in the Development Process
Develop the Model Objects
Adding Managed Bean Declarations
Creating the Pages
Define Page Navigation
The Lifecycle of a JavaServer Faces Page
Request Processing Lifecycle Scenarios
Standard Request Processing Lifecycle
User Interface Component Model
The User-Interface Component Classes
The Component Rendering Model
Conversion Model
Event and Listener Model
Validation Model
Navigation Model
Managed Bean Creation
Application Configuration
About the Examples
Running the Examples Using the Pre-Installed XML Files
Building and Running the Sample Applications Manually
The cardemo Example
Basic Requirements of a JavaServer Faces Application
Writing the web.xml File
Including the Required JAR Files
Including the Classes, Pages, and Other Resources
Invoking the FacesServlet
Setting Up The Application Configuration File
Creating Model Objects
Using the managed-bean Element
Initializing Properties using the managed-property Element
Binding a Component to a Data Source
How Binding a Component to Data Works
Binding a Component to a Bean Property
Binding a Component to an Initial Default
Combining Component Data and Action Objects
Using the JavaServer Faces Tag Libraries
Declaring the JavaServer Faces Tag Libraries
Using the Core Tags
Using the HTML Tags
Writing a Model Object Class
Writing Model Object Properties
Performing Validation
Displaying Validation Error Messages
Using the Standard Validators
Creating a Custom Validator
Performing Data Conversions
Using the Standard Converters
Creating and Using a Custom Converter
Handling Events
Implementing an Event Listener
Registering Listeners on Components
Navigating Between Pages
What is Navigation?
How Navigation Works
Configuring Navigation Rules in faces-config.xml
Referencing An Action From a Component
Using an Action Object With a Navigation Rule
Performing Localization
Localizing Static Data
Localizing Dynamic Data
Localizing Messages
Determining if You Need a Custom Component or Renderer
When to Use a Custom Component
When to Use a Custom Renderer
Component, Renderer, and Tag Combinations
Understanding the Image Map Example
Why Use JavaServer Faces Technology to Implement an Image Map?
Understanding the Rendered HTML
Understanding the JSP Page
Simplifying the JSP Page
Summary of the Application Classes
Steps for Creating a Custom Component
Creating the Component Tag Handler
Defining the Custom Component Tag in a Tag Library Descriptor
Creating Custom Component Classes
Extending From a Standard Component
Performing Encoding
Performing Decoding
Delegating Rendering to a Renderer
Create the Renderer Class
Register the Renderer with a Render Kit
Identify the Renderer Type
Register the Component
Handling Events for Custom Components
Using the Custom Component in the Page
Further Information
Java Platform Localization Classes
Providing Localized Messages and Labels
Date and Number Formatting
Character Sets and Encodings
Character Sets
Character Encoding
Further Information
Security in the Web-Tier
Realms, Users, Groups, and Roles
Setting up Security Roles
Managing Roles and Users
Specifying Security Constraints
Specifying a Secure Connection
Using Login Authentication
Example: Using Form-Based Authentication
Using Programmatic Security in the Web Tier
Declaring and Linking Role References
Installing and Configuring SSL Support
What is Secure Socket Layer Technology?
Setting Up Digital Certificates
Configuring the SSL Connector
XML and Web Services Security
Transport-Level Security
Example: Basic Authentication with JAX-RPC
Example: Client-Certificate Authentication over HTTP/SSL with JAX-RPC
Message-Level Security
Coffee Break Overview
Common Code
JAX-RPC Distributor Service
Service Interface
Service Implementation
Publishing the Service in the Registry
Deleting the Service From the Registry
SAAJ Distributor Service
SAAJ Client
SAAJ Service
Coffee Break Server
JSP Pages
JavaBeans Components
RetailPriceListServlet
Building, Installing, and Running the Application
Setting the Port
Building the Common Classes
Building and Installing the JAX-RPC Service
Building and Installingthe SAAJ Service
Building and Installingthe Coffee Break Server
Running the Coffee Break Client
Removing the Coffee Break Application
Running admintool
Configuring Tomcat
Setting Server Properties
Configuring Services
Configuring Connector Elements
Configuring Host Elements
Configuring Logger Elements
Configuring Realm Elements
Configuring Valve Elements
Configuring Resources
Configuring Data Sources
Configuring Environment Entries
Configuring User Databases
Administering Roles, Groups, and Users
Managing Roles
Managing Users
Further Information
Running the Web Application Manager
Running Manager Commands Using Ant Tasks
Starting the Registry Server
Using JAXR to Access the Registry Server
Adding and Deleting Users
Adding a New User to the Registry
Deleting a User from the Registry
Further Information
Starting the Browser
Querying a Registry
Querying by Name
Querying by Classification
Managing Registry Data
Adding an Organization
Adding Services to an Organization
Adding Service Bindings to a Service
Adding and Removing Classifications
Submitting the Data
Deleting an Organization
Stopping the Browser
HTTP Requests
HTTP Responses
Further Information