search for books and compare prices
Tables of Contents for Professional Java Server Programming
Chapter/Section Title
Page #
Page Count
Introduction
1
6
Java and the J2EE Platform
7
28
The Enterprise Today
8
6
System Architecture
9
1
2-Tier Architecture
9
1
3-Tier Architecture
10
1
n-Tier Architecture
10
1
Enterprise Architecture
11
1
Is Java the Answer?
12
1
Platform Independence
13
1
Reusability
13
1
Modularity
13
1
The J2EE Platform
14
3
The J2EE Runtime
14
1
The J2EE APIs
15
2
J2EE Architecture - Containers
17
6
Container Architecture
18
1
Component Contracts
19
1
Container Service APIs
20
1
Declarative Services
21
1
Other Container Services
22
1
J2EE Technologies
23
6
Component Technologies
23
1
Web Components
24
1
Enterprise JavaBean Components
25
1
Service Technologies
25
1
JDBC
25
1
Java Transaction API and Service
25
1
JNDI
26
1
Communication Technologies
26
1
Internet Protocols
26
1
Remote Object Protocols
27
1
JMS
27
1
JavaMail
27
1
XML
27
2
Developing J2EE Applications
29
3
J2EE Application Development and Deployment Roles
29
1
Application Component Development
30
1
Composition of Application Components into Modules
30
1
Composition of Modules into Applications
30
1
Application Deployment
31
1
Summary
32
3
Distributed Computing Using RMI
35
64
RMI Alternatives
36
1
The RMI Architecture
36
4
The Stub and Skeleton Layer
38
1
Stubs
38
1
Skeletons
39
1
The Remote Reference Layer
39
1
The Transport Layer
39
1
Locating Remote Objects
40
3
Policy Files
43
1
RMI Exceptions
43
2
Developing Applications with RMI
45
5
Defining the Remote Interface
45
1
Implementing the Remote Interface
46
1
Writing the Client That Uses the Remote Objects
47
1
Generating Stubs and Skeletons
48
1
Registering the Object
48
1
Running the Client and Server
49
1
The RMISecurityManager
50
1
Parameter Passing in RMI
50
2
Primitive Parameters
50
1
Object Parameters
51
1
Remote Parameters
51
1
The Distributed Garbage Collector
52
4
Dynamically Loading Classes
56
4
Remote Callbacks
60
3
Object Activation
63
12
The Activation Group
64
2
ActivationID
66
1
Activation Descriptor
66
2
Making Objects Activatable
68
1
Create the Remote Interface
68
1
Create the Object Implementation
69
1
Register the Object with the System
69
2
Alternative to Extending the Activatable Class
71
1
Starting Multiple JVMs Other Than rmid
72
2
Deactivation
74
1
Custom Sockets and SSL
75
13
RMI, Firewalls, and HTTP
88
2
HTTP Tunneling
88
1
HTTP-to-Port
88
1
HTTP-to-CGI
89
1
The SOCKS Protocol
90
1
Downloaded Socket Factories
90
1
RMI Over IIOP
90
7
Interoperability with CORBA
91
1
RMI-IIOP and Java IDL
92
1
Writing Programs with RMI-IIOP
92
1
On the Server
93
1
In the Client
94
2
RMI-IIOP and J2EE
96
1
Summary
97
2
Database Programming with JDBC
99
68
Database Drivers
101
3
JDBC-ODBC Bridge
101
1
Part Java, Part Native Driver
102
1
Intermediate Database Access Server
103
1
Pure Java Drivers
103
1
The JDBC 2.1 Core API
104
30
Loading a Database Driver and Opening Connections
106
1
JDBC URLs
106
1
DriverManager
107
3
Driver
110
1
Establishing a Connection
110
2
Creating and Executing SQL Statements
112
1
An Example: Movie Catalog
113
5
Querying the Database Using the ResultSet Interface
118
3
Prepared Statements
121
2
Mapping SQL Types to Java
123
2
Transaction Support
125
1
Scrollable and Updatable Result Sets
126
1
Scrollable Result Sets
127
5
Updatable Result Sets
132
1
Batch Updates
133
1
The JDBC 2.0 Optional Package API
134
1
JDBC Data Sources
135
6
The javax.sql.DataSource Interface
135
1
The getConnection() Method
135
1
The getLoginTimeout() Method
136
1
The setLoginTimeout() Method
136
1
The getLogWriter() Method
136
1
The setLogWriter() Method
136
1
JNDI and Data Sources
137
1
Creating a Data Source
138
1
Retrieving a Data Source
139
1
Key Features
140
1
The Movie Catalog Revisited
140
1
Connection Pooling
141
6
Traditional Connection Pooling
142
2
JDBC 2.0 Connection Pooling
144
1
The javax.sql.ConnectionPoolDataSource Interface
145
1
The javax.sql.PooledConnection Interface
145
1
The javax.sql.ConnectionEventListener Interface
146
1
The javax.sql.ConnectionEvent Class
147
1
Connection Pooling Implementation
147
1
Distributed Transactions
147
10
What is a Transaction?
148
1
Brief Background
148
1
Transaction Processing-Concepts
149
1
Transaction Demarcation
149
1
Transaction Context and Propagation
149
1
Resource Enlistment
150
1
Two-Phase Commit
150
1
Building Blocks of Transaction Processing Systems
150
1
Application Components
150
1
Resource Managers
151
1
Transaction Manager
151
1
JDBC 2.0 Distributed Transactions
152
1
The javax.sql.XADataSource Interface
152
1
The javax.sql.XAConnection Interface
152
1
The javax.transaction.UserTransaction Interface
153
1
Steps for Implementing Distributed Transactions
154
1
Configuration
154
1
Beginning a Transaction
154
1
Database Operations
155
1
Ending a Transaction
156
1
Special Precautions
156
1
RowSets
157
6
The javax.sql.RowSet Interface
158
1
Properties
158
1
Events
159
1
Command Execution and Results
159
1
Types of Rowsets
160
1
Cached Rowsets
160
2
JDBC Rowsets
162
1
Web Rowset
162
1
Summary
163
4
JNDI and LDAP
167
50
Naming and Directory Services
167
3
Naming Services
168
1
Directory Services
168
2
Enter LDAP
170
6
Access Control
170
1
Authentication
170
1
Authorization
171
1
White Pages Services
171
1
Distributed Computing Directory
171
1
Application Configuration
172
1
LDAP Data
172
4
Introducing JNDI
176
4
Using JNDI
178
1
Installing JNDI
178
1
JNDI Service Providers (JNDI Drivers)
179
1
How to Obtain JNDI Service Providers
179
1
Developing Your Own Service Provider
180
1
Basic LDAP Operations
180
21
Standard LDAP Operations
180
1
Connecting to the LDAP Server
181
1
Authentication (LDAP Bind)
182
1
Simple
183
1
SSL/TLS
183
1
SASL
183
1
Searching an LDAP Server
184
1
Example LDAP Filters
184
1
LDAP Search Base and Scope
185
1
Searching with JNDI
186
2
How the Search Program Works
188
2
Authenticated Searching
190
1
Restricting the Attributes Displayed
191
2
Working with LDAP Entries
193
1
Adding Entries
193
5
Modifying an Entry
198
2
Deleting an Entry
200
1
Storing and Retrieving Java Objects in LDAP
201
2
Traditional LDAP
201
1
Serialized Java Objects
202
1
Java References
202
1
DSML
203
1
A Bank Account JNDI Application
203
12
Using LDAP with RMI
204
1
Application Background
205
1
JNDIRemoteBankInterface
206
1
JNDIRemoteBankServer
206
4
JNDIRemoteBankClient
210
1
The Account Class
211
1
Running the Application
211
1
RMI Without the Registry
212
1
Storing Java Objects in the Directory
213
1
Building an Object Directory
214
1
Summary
215
2
XML Beginnings
217
48
A Primer on XML
218
6
XML and XML Documents
218
1
Some Simple Examples
218
2
Clarification on Entities, and a Bit of Terminology
220
1
A Note on XML Processors/Parsers
220
1
Why XML is Great
221
1
Main Uses of XML
222
1
Java and XML; XML within J2EE
222
1
XML within the EJB Container: Deployment Descriptors
223
1
XML within the Web Container: web.xml
223
1
XML for Integrating Legacy Data
223
1
XML and EDI
224
1
A Primer on XML Technologies
224
4
The Standardization Process and the Role of W3C
225
1
SGML and XML
225
1
DTDs and XML Schema
226
1
XML Styling
226
1
Stylesheets and Current Browsers
227
1
Namespaces
227
1
Well-Formedness Constraints
228
3
Attribute Quoting
228
1
Tree Structure
228
1
Explicit Tree Structure in Markup
228
1
An HTML/XHTML/XML Example
229
1
From HTML to XHTML
230
1
The Logical Structure of an XML Document
231
11
XML Documents Without a DTD
231
1
A Kitchen-Sink Document Without a DTD
232
1
XML Declarations and Character Encodings
232
1
Comments and Processing Instructions
233
1
The Root Element and its Contents
234
1
Character Entities and Pre-Declared Entities
235
1
CDATA Sections
235
1
XML Documents with DTDs
236
1
A Simple Example: DOCTYPE, ELEMENT, and ATTLIST
237
1
ELEMENT Declarations
238
1
Attribute Declarations
239
1
DTD and Entities
240
1
Parameter Entities vs. General Entities
241
1
Internal and External Entities
241
1
External Identifiers - System and Public
241
1
An Example of Entity Declarations and References
241
1
Read Well-Known DTDs
242
1
DTDs, Parsers, and Validation
242
3
Parsers and DTDs
242
1
XML Schemas
243
1
DTD Validators
244
1
XML Namespaces
245
4
The Main Idea - A Prefix and a URI
245
1
A Big Caveat
246
1
The Scope of the Namespace Declaration
247
1
The Default Namespace
247
1
Namespaces and Attribute Names
248
1
Namespaces and DTDs
249
1
Styling XML with CSS
249
4
A CSS1 Example, and an Explanation
249
2
Selectors and Declarations
251
1
The Syntax of Selectors
251
1
Properties and Values
252
1
Namespaces and CSS
253
1
Styling XML with XSLT
253
9
What's XPath?
254
1
Trying Out XSLT
254
1
XML Data
255
1
A Stylesheet Walkthrough
255
2
Declarations and Top-Level Parameters
257
1
Match the Root of the Document Tree
258
1
The First Block of XHTML Material for Output
258
1
Match and Collect Elements
258
1
Output the Collected Elements, or a Message
258
1
A Slight Variation
259
1
A Bit More Power
260
2
Coming Attractions
262
1
Summary
263
2
XML Parsing with DOM and SAX
265
54
The Origins of DOM and SAX
266
1
How Does JAXP Fit In?
266
1
The Specific Parser
267
1
Chapter Outline
267
1
SAX, JAXP, and a Simple Example
267
6
SAX Overview
268
1
More on DocumentHandler
268
1
The Structure of JAXP
269
1
A Simple Example: Count the Elements
270
1
Program Structure
270
1
Variations on Parsing
271
1
The org.xml.sax.Parser Class
272
1
DOM and Our Example Revisited
273
2
Node Types
273
1
Node Methods
273
1
Element Counting with DOM
274
1
Overview of This Chapter's Applications
275
7
Two Utility Classes
276
1
The PropDict Class
276
1
PropDict Code
276
4
Web Applications and Local Applications
280
1
The Logger Class
280
1
The Log File
280
1
Control of Logging
281
1
The Logger Code
281
1
A DOM Application
282
12
Local and Web
283
1
The DomSearch Class
283
1
The main() Method
284
1
Overview
285
1
doCommand()
285
1
initFile(), readFile(), and readDoc()
286
3
nextMatch()
289
2
resetNode()
291
1
Output Methods
291
1
Constructor and Get/Set Methods
292
2
DOM in Depth
294
7
DOM Level 1
294
1
XML, DOM, and Language Bindings
295
1
Node Types in DOM
295
1
Numeric Constants for Node Types
296
1
DOM Features Not in the XML 1.0 Specification
296
1
On Document Fragments
297
1
DOM Bindings
297
1
An Example of IDL and Java Bindings
298
1
The Structure of the Java Binding
299
2
A SAX Application
301
11
SAX Reminders
302
1
Sax2Writer
302
1
The main() Method
302
1
Imports, Declarations, Constructors, Set Methods
303
1
The parse() Method and newParser()
303
1
DocumentHandler Methods
304
1
Output Methods
305
1
Dom2Sax
306
1
Imports, Declarations, and Constructors
307
1
Set Methods
308
1
parse() Methods
308
1
Recursive Parse and its Helpers
309
2
The main() Method
311
1
parseOpen() and parseClose()
311
1
SAX Parsing of Java Objects and SAX Filters
312
5
Parsing Objects that are Not XML Text
312
2
A Virtual Parsing Example
314
2
Extending the Chain: SAX Filters
316
1
Summary
317
2
Introduction to Web Containers
319
22
The HTTP Protocol
320
2
HTTP Request Methods
320
1
The GET Request Method
321
1
The POST Request Method
321
1
HTTP Response
321
1
Web Containers and Web Applications
322
7
Java Servlets
323
3
JavaServer Pages
326
1
Deployment Descriptors
327
1
Structure of Web Applications
328
1
Types of Web Containers
328
1
Your First Web Application
329
4
Prepare the Web Container
330
1
Create the HTML File
330
1
Create a Servlet
330
2
Compile the Source
332
1
Write the Deployment Descriptor
332
1
Test the Application
332
1
The Making of Your Web Application
333
6
How the Application Works
333
1
Import the Servlet Packages
334
1
Class Declaration
335
1
Service the HTTP POST Request
335
2
The Deployment Descriptor
337
1
Location of the Application
338
1
Summary
339
2
Servlet Programming
341
48
Overview of the Java Servlet API
342
3
Servlet Implementation
345
6
The Servlet Interface
345
1
The init() Method
346
1
The service() Method
346
1
The destroy() Method
346
1
The getServletConfig() Method
347
1
The getServletlnfo() Method
347
1
The GenericServlet Class
347
1
The SingleThreadModel Interface
348
1
The HttpServlet Class
349
1
The service() Methods
349
1
The doXXX() Methods
350
1
The getLastModified() Method
350
1
Servlet Configuration
351
2
The ServletConfig Interface
351
1
The getInitParameter() Method
352
1
The getInitParameterNames() Method
352
1
The getServletContext() Method
352
1
The getServletName() Method
352
1
Obtaining a Reference to ServletConfig
352
1
During Servlet Initialization
352
1
Using the getServletConfig() Method
353
1
Servlet Exceptions
353
1
The ServletException Class
353
1
The UnavailableException Class
354
1
The Servlet Lifecycle
354
3
The Servlet Lifecycle - FreakServlet
357
8
Instantiation
361
1
Initialization
361
1
Service
362
2
Destroy
364
1
API for Requests and Responses
365
10
The ServletRequest Interface
366
1
Methods for Request Parameters
366
1
Methods for Request Attributes
367
1
Methods for Input
368
1
The HttpServletRequest Interface
368
2
Methods for Request Path and URL
370
1
Methods for HTTP Headers
371
1
The getMethod() Method
371
1
The ServletResponse Interface
371
1
Methods for Content Type and Length
372
1
Methods for Output
372
1
Methods for Buffered Output
373
1
The HttpServletResponse Interface
374
1
Methods for Error Handling
374
1
The sendRedirect() Method
375
1
Servlet Programming - Tech Support Application
375
12
Setting up the HTML Page
375
2
Prepare the Database
377
2
Creating a Sequencer
379
1
Writing the Servlet
380
3
Compile the Source
383
1
Deployment Descriptor
383
1
Tech Support in Action
384
2
Note on Database Connections
386
1
Summary
387
2
Servlet Sessions, Context, and Collaboration
389
60
Statelessness and Sessions
390
2
Approaches to Session Tracking
392
4
URL Rewriting
393
1
Hidden Form Fields
394
1
Cookies
394
2
Session Tracking with the Java Servlet API
396
19
Session Creation and Tracking
397
1
The HttpSession Interface
398
1
Methods for Session Lifetime
398
2
Demonstrating Session Lifecycle with Cookies
400
4
Session Lifecycle Without Cookies
404
1
Methods for Managing State
404
2
Demonstrating State Management
406
2
Binding and Unbinding Objects to and from Sessions
408
1
The HttpSessionBindingListener Interface
409
1
The HttpSessionBindingEvent Class
409
1
A Simple Shopping Cart Using Sessions
410
1
The Catalog Servlet
410
2
The ShoppingCart Servlet
412
3
Servlet Context
415
18
The ServletContext Interface
415
2
A Chat Application Using Context and Sessions
417
2
The ChatRoom Class
419
1
The ChatEntry Class
420
1
The Administration Servlet
420
3
Servlets for Chatting
423
8
Chat Setup
431
2
Servlet Collaboration
433
14
Servlet Chaining
433
1
Request Dispatching
434
1
RequestDispatcher Interface
434
1
Obtaining a RequestDispatcher Object
435
1
Tech Support Revisited
435
1
The techsupp.html Page
436
1
TechSupportServlet
437
2
The register.html Page
439
1
RegisterCustomerServlet
440
2
ResponseServlet
442
1
BannerServlet
443
1
TechSupport Setup and Deployment
444
1
Using RequestDispathers for Collaboration
445
2
Summary
447
2
Web Deployment, Authentication, and Packaging
449
26
Structure of a Web Application
449
4
Directory Structure
450
2
Web Archive Files
452
1
Mapping Requests to Applications and Servlets
453
5
Securing Web Applications
458
7
Programmatic Security
461
1
Form-Based Authentication
461
4
Deployment Configuration
465
8
Context Initialization Parameters
465
1
Servlet Initialization Parameters
466
1
Loading Servlets on Startup
467
1
Session Timeout
467
1
MIME Mappings
468
1
Welcome Files
469
1
Error Pages
469
1
Sending Errors
469
1
Throwing ServletException
470
1
Handling HTTP Errors and Exceptions
471
1
Distributable Applications
472
1
Summary
473
2
JSP Basics and Architecture
475
52
Introducing JSP
475
5
The Nuts and Bolts
480
31
JSP Directives
481
1
The page Directive
481
3
The include Directive
484
2
The taglib Directive
486
1
Scripting Elements
486
1
Declarations
487
1
Scriptlets
488
1
Expressions
489
1
Standard Actions
490
1
<jsp:useBean>
491
2
<jsp:setProperty>
493
2
<jsp:getProperty>
495
3
<jsp:param>
498
1
<jsp:include>
498
4
<jsp:forward>
502
3
<jsp:plugin>
505
1
Implicit Objects
506
1
The request Object
507
1
The response Object
507
1
The pageContext Object
507
1
The session Object
507
1
The application Object
507
1
The out Object
508
1
The config Object
508
1
The page Object
508
1
Scope
508
1
Page Scope
508
1
Request Scope
509
1
Session Scope
509
1
Application Scope
509
1
XML Equivalent Tags
509
1
DTD and Root Element
509
1
Directives
510
1
Scripting Elements
510
1
Actions
510
1
JSP Design Basics
511
2
Page-Centric or Client-Server Designs
511
1
Page-View
512
1
Page-View with Bean
512
1
The `Dispatcher' Approach
513
2
Mediator-View
513
1
Mediator-Composite View
513
1
Service to Workers
514
1
JSP Technical Support
515
10
Application Design
517
1
The Welcome Page
517
1
The Request-Processing JSP
518
1
The TechSupportBean
519
2
The Registration Form
521
1
The Registration JSP
522
1
The Response and Banner JSPs
523
1
The Error Page
523
1
Deploying the Application
524
1
Summary
525
2
JSP Tag Extensions
527
46
Tag Extension 101
527
8
A Simple Tag
530
2
Getting it Running
532
3
Anatomy of a Tag Extension
535
14
Tag Handlers
535
1
The javax.servlet.jsp.tagext.Tag Interface
536
2
The javax.servlet.jsp.tagext.BodyTag Interface
538
1
The javax.servlet.jsp.tagext.BodyContent Class
539
1
Convenience Classes
540
1
The javax.servlet.jsp.tagext.TagExtralnfo Class
541
1
Objects Available to Tag Handlers
541
1
The Simple Example Revisited
542
1
Tag Library Descriptors
543
2
Using Tag Extensions in JSP Pages
545
1
Deploying and Packaging Tag Libraries
546
1
No Packaging
546
1
WAR
546
1
Tag Library JAR
547
2
Combination of WAR and JAR
549
1
Writing Tag Extensions
549
20
Processing Attributes
549
3
Body Content
552
1
Tags Introducing Scripting Variables
553
1
Specifying a TagExtralnfo Class
554
1
Implementing the TagExtralnfo Class
554
1
Changes to the Tag Handler
555
1
An Example
555
2
Body Tags
557
1
Body Tags and Iteration
558
4
Body Tags That Filter Their Content
562
2
Tag Nesting
564
5
Handling Errors
569
1
Tag Extension Idioms
569
2
Summary
571
2
Advanced Custom JSP Tags
573
42
An XSL Style Tag
573
5
Swing Model Tags
578
25
Using the Swing ListModel
579
3
Creating a Name-Value Mapping Model
582
5
Using the Swing TableModel
587
16
Delivery
603
1
Under the Hood
604
4
Third Party Custom Tags
608
5
Flow Control
608
2
J2EE Technologies
610
1
Client-Side Validation
611
2
Tools Support and Future Directions
613
1
Summary
613
2
Writing Maintainable JSP Pages
615
70
The Goal
616
1
JSPs in a Multi-Tier Architecture
617
2
Techniques for Writing Maintainable JSPs
619
17
Request Controller Architecture
619
1
Implementing Request Controller Architecture
620
3
When Not to Use a Request Controller Architecture
623
1
Using Includes in JSP
623
1
Two Types of Includes
623
1
Using Static Includes
624
1
Using JSP Beans
625
1
Page Beans
626
1
Session Beans
626
1
Application Beans
626
1
Bean Configuration
627
1
Dos and Don'ts
627
1
Using Tag Extensions
627
1
Categories of Tags
628
1
Model Tags
629
1
Translation Tags
629
1
Tags as Application Building Blocks
629
1
Third Party Tag Libraries
629
1
Dos and Don'ts
630
1
Handling Iteration
630
1
Handling Conditional Logic
631
2
Using Styled XML
633
1
When to Use Custom Superclasses for JSPs
633
1
Standard Abstractions for Common Objects
634
1
Handling Exceptions
634
1
Internationalization
634
2
Documenting the JSP Layer
636
1
Tool Support
637
1
Coding Standards for Maintainable JSPs
637
5
Design Principles and Coding Style
637
3
Formatting JSP Pages
640
2
The DBExplorer Application
642
40
Requirements
642
3
Design
645
1
Implementation
646
1
Presentation Tier - The ui and ui.requesthandlers Packages
647
25
Data Tier - The datasources and datasources.db Packages
672
8
Reviewing the Application
680
1
Deploying the Application
680
2
Summary
682
3
JSP and XML - Working Together
685
62
JSP and XML
686
1
Modular Design and Modular Reading
686
1
A Profiled Newsletter - A Case Study
687
7
Caveats
687
1
The Main Design Features
688
1
An Overview of the Main Components
688
2
Try It Out
690
4
The Configuration Component
694
16
The Reflection Package
694
1
The Constructor Class
695
1
Invoking Methods
695
1
A Config File Example
696
2
The Meaning of Tags
698
1
The Meaning of Attributes
699
1
The Java Code for XML Configuration
699
1
Config Classified
700
1
The Control Pattern of Config()
701
2
Where Are We?
703
1
configChild() and Method Invocation
704
3
apply() and getMethod() - Invoking the Right Method
707
3
JSPs and the Configuration File
710
1
The Database Component
710
16
DBConnector and Its Default Implementation
711
2
QueryHandler
713
1
The Main Class
714
1
The DBQuery Class
715
1
Utilities
716
2
XML Configuration for QueryHandler
718
1
ResultSetParser
718
1
parse() and parseLoop()
719
1
The Rest of It
720
3
UserDataHandler
723
1
Imports, Declarations and Instantiation
723
3
XML Data Access Component
726
4
DomSearch Queries
726
1
DomSearch vs. XSLT
727
1
DomSearch Output
727
1
Instantiating DomSearch - DSNextMatch
727
1
Configuration XML data for DomSearch
728
1
Using DomSearch During a Session
729
1
The Presentation Component
730
7
The Login Page
730
1
The Main Frames Page and Initialization
730
1
Control and Data Frames
731
2
The Logout Page - spLogout.jsp
733
1
The Change-Configuration Page - spConfigure.jsp
733
1
The Query Results Page - spQuery.jsp
734
3
The Control Component
737
6
The StampPageFactory Bean
737
2
The Configuration Methods and the Configuration File
739
1
The Rest of It
740
1
The StampPage Bean
741
2
Extensions to the Basic Functionality
743
1
Summary
744
3
An XML-Based JDBC Connector Servlet Framework
747
64
Implementing the JDBC Connector Servlet
748
41
The Framework's Functional Requirements
748
2
The JCS Architecture
750
1
The JCS Scripting Framework
751
2
JCS Query Tags
753
3
Variable Types
756
2
The Java Classes that Implement JCS
758
1
The com.jresource.util Package
759
5
The com.jresources.jdbc Package
764
2
The com.jresources.jcs Package
766
16
The com.jresources.servlets Package
782
2
Other Artifacts
784
1
The JSP Custom Tag Library Descriptor (jcs_taglib.tld)
784
1
The Web Application Deployment Descriptor (web.xml)
784
2
Packaging the Framework for J2EE Deployment
786
1
Compile the Java Classes
787
1
Package the Bytecode into a Jar
787
1
Generate the Javadoc Documentation
787
1
Package the Application into a War
787
1
Deploying JCS to a J2EE Servlet Container
788
1
Using the JDBC Connector Servlet
789
20
The Guestbook Sample Application
789
2
Creating a Select query
791
2
Creating an Insert Query
793
1
Creating a Delete Query
794
1
Generating Default XML Output (JDBC Resultset Serialized as XML)
794
1
Generating Custom XML Output
795
1
Using the jcsEngine Bean in a JSP Page
796
3
Using the <jcs:query_object> Custom Tag in a JSP Page
799
1
Using XSLT with JCS
799
4
The SQL Server Database Browser Application
803
1
Enumerating Through SQL Server Tables
804
2
Serializing a SQL Server Table as an XML Document
806
1
Executing an Arbitrary SQL Statement
807
2
Summary
809
2
JavaMail
811
52
Setup Instructions
812
1
The Provider Registry
812
1
The JavaMail API
813
31
javax.mail.Session
814
1
Session Properties
815
1
javax.mail.Authenticator and Password/Authentication
816
1
javax.mail.Message
817
1
Constructing a Message
818
1
Message Headers
818
4
Message Flags
822
2
javax.mail.Part
824
1
Activation
824
1
Content
825
2
Part Headers
827
2
javax.mail.Multipart and BodyPart
829
1
javax.mail.internet.MimePart
830
1
javax.mail.internet.MimeMessage
831
1
javax.mail.internet.MimeMultipart and MimeBodyPart
832
2
javax.mail.Service
834
1
javax.mail.Transport
835
2
javax.mail.Store
837
1
javax.mail.Folder
838
6
javax.mail.search.*
844
1
Working Example
845
15
Summary
860
3
EJB Architecture and Design
863
42
Enterprise JavaBeans vs. JavaBeans
864
1
What Are EJBs?
865
4
Varieties of Beans
866
1
Why Use EJBs In Your Design?
867
2
The EJB Container and Its Services
869
5
Persistence
869
1
Declarative Transactions
870
1
Data Caching
870
1
Declarative Security
870
1
Error Handling
870
1
Component Framework for Business Logic
870
1
Scalability and Fail-Over
871
1
Portability
871
1
Manageability
871
1
How the Container Provides Services
871
1
Contracts
872
1
Services
873
1
Interposition
873
1
Working with EJBs
874
13
The Client Developer's View
875
3
The Bean Programmer's View
878
6
What You Can't Do in an EJB Component
884
1
You Can't Use Threads or the Threading API
885
1
You Can't Use the AWT
885
1
You Can't Act as a Network Server
885
1
You Can't Use Read/Write Static Fields
886
1
You Can't Use the java.io Package
886
1
You Can't Load a Native Library
886
1
You Can't Use ``this'' as an Argument or Return Value
886
1
You Can't/Shouldn't Use Loopback Calls
886
1
EJB Components on the Web
887
2
Client-Tier Access to EJBs
889
1
Design of the EJB Tier
890
13
UML Use Cases
891
1
Analysis Objects
891
2
Analysis vs. Implementation
893
2
The Role of State in the Interface Object
895
1
An Example of EJB Design
895
2
Create a Product
897
1
Place an Order
897
1
Cancel an Order
897
1
Select an Order for Manufacture
898
1
Build a Product
898
1
Ship an Order
898
1
List Overdue Orders
898
5
Summary
903
2
Session Beans and Business Logic
905
62
Session Beans and State
906
6
Representing Business Logic
906
3
The Difficult Problem of Conversational State
909
2
Session Beans and Persistent Storage
911
1
The Financial Aid Calculator Bean
912
20
The Stateless Financial Calculator Bean
912
8
The Stateful Financial Calculator Bean
920
7
Combining Stateful and Stateless Beans
927
5
Implementing Our Manufacturing Application
932
33
Clients and the Business Logic Interfaces
934
14
Stateless Session Bean Implementation
948
1
Business Methods
948
7
Implementation Helper Methods
955
2
Lifecycle and Framework Methods
957
1
Stateful Session Bean Implementation
958
7
Summary
965
2
Entity Beans and Persistence
967
62
Why Not Use Session Beans?
968
5
Using a Stateful Session bean
968
3
Using a Stateless Session Bean
971
2
Benefits of Entity Beans
973
1
Container- vs. Bean-Managed Persistence
973
34
The SportBean Laboratory
975
1
Primary Keys
976
1
The C.R.U.D. Callbacks
976
12
BMP Callbacks vs. CMP Callbacks
988
1
The Deployment Descriptor
989
1
Caching
990
3
Finder Methods
993
3
Activation and Passivation
996
1
The Complete Lifecycle
996
1
Reentrancy
997
1
Completing the Sports Team Example
998
9
Relationships
1007
1
Completing Our Manufacturing Application
1008
19
The Order Bean
1008
6
The Product Bean
1014
4
The Complete Deployment Descriptor
1018
3
Running the Manufacturing Application
1021
6
Summary
1027
2
EJB Container Services
1029
42
Transactions
1031
19
Transactions Without a Container
1032
8
Declarative Semantics for Transactions
1040
1
The `NotSupported' Transactional Attribute
1040
1
The `Supports' Transactional Attribute
1040
1
The `RequiresNew' Transactional Attribute
1041
1
The `Required' Transactional Attribute
1041
1
The `Mandatory' Transactional Attribute
1041
1
The `Never' Transactional Attribute
1041
1
Specifying Transactional Attributes
1041
1
Choosing Transaction Attributes
1042
2
User-Controlled Transactions
1044
2
Isolation Levels
1046
2
Long Transactions
1048
1
Optimistic Locking
1049
1
Pessimistic Locking
1049
1
Two-Phase Commit
1050
1
Security
1050
8
Specifying the Security Requirements
1052
1
Security Roles
1052
2
Method Permissions
1054
1
Programmatic Access Control
1055
3
Security and Application Design
1058
1
Exceptions
1058
7
Application Exceptions
1059
3
Predefined Application Exceptions
1062
1
System Exceptions
1062
3
Communication
1065
3
Communication Between Heterogeneous Servers
1065
2
In-VM Method Calls
1067
1
Summary
1068
3
Development and Deployment Roles
1071
58
The Enterprise Bean Provider
1073
12
The Application Assembler
1085
8
The Deployer
1093
4
The System Administrator
1097
2
Container/Application Server Vendor
1099
1
A Web Interface for the Manufacturing App
1100
24
Troubleshooting Tips
1124
2
Summary
1126
3
Enterprise JavaBeans 2.0
1129
48
New Features of EJB 2.0
1130
1
Container-Managed Persistence in EJB 2.0
1131
24
The cmp-field Type
1134
2
The cmr-field Type
1136
1
If the endpoint is a dependent object class...
1137
1
If the endpoint is an entity bean...
1137
1
How to Specify the Relationship in the Deployment Descriptor
1138
5
The Complete CMP 2.0 Deployment Descriptor
1143
4
Coding CMP 2.0 Beans
1147
1
Fields
1147
1
Relationships
1148
1
The Manufacturing Sample Application
1149
6
The EJB 2.0 Query Language
1155
8
Where Does the Programmer Specify a Query?
1156
1
How Does the Programmer Specify a Query?
1157
1
The Concept of the Schema
1158
1
Understanding the Context
1158
1
Navigation Operator ``.''
1159
1
Navigating Over Collections
1159
1
Input Parameters
1160
1
Other Entity Beans
1160
1
Where Clause Options
1161
1
Queries from the Manufacturing Application
1162
1
Message-Driven Beans
1163
3
Business Methods in the Home Interface
1166
7
Summary
1173
4
Design Considerations for J2EE Applications
1177
32
The World is Changing
1178
1
Design Context
1179
2
On Architecture and Design
1181
5
Architectural Styles
1182
2
Forces, Patterns, and Iteration
1184
2
Distributed Design
1186
1
Start at the Beginning
1187
3
Adding the Middle Tier
1190
2
Going Shopping
1192
2
Submitting and Processing the Order
1194
3
Lessons Learned
1197
3
Use Model-View-Controller (MVC) for User Interaction
1197
1
JSP Design Principles
1198
1
Choosing an Appropriate Data Format
1198
1
Reduce the Amount of Data Passed
1199
1
Design Interfaces for Distribution
1199
1
Use Messaging for Asynchronous Operations
1200
1
Plan Transactions
1200
1
Beyond the Purchase Order System
1200
4
EJB Interface Design
1200
1
Distributed Events
1201
1
Working with Databases
1202
1
State Management
1203
1
On Architecture and Process
1204
1
Summary
1205
4
Performance and Scalability
1209
50
Life is a Compromise
1210
4
Time-to-Market
1211
1
The Upside and Downside of Delegation
1212
2
The Importance of Being Scalable
1214
2
Denial of Service?
1216
1
Performance
1216
19
Coding Issues
1217
1
Performance Testing and Tuning
1217
1
Performance Analysis
1218
1
Prioritize
1218
1
Corrective Action
1219
1
Design-Time Issues
1220
1
Component-level Architecture
1221
3
Granularity
1224
2
Container Overheads
1226
1
The Art of Component Granularity
1226
4
Transactional Granularity
1230
1
Persistence Granularity
1231
1
Security and Performance
1232
1
Service-Level Architecture
1232
1
The Object Soup
1233
1
Component Partitioning
1234
1
Caching Strategies
1234
1
Scalability
1235
20
Scalability and Performance Testing
1237
1
Tips, Tools, and Techniques
1237
2
Designing for Good Scalability
1239
1
Concurrency
1239
5
Optimistic and Pessimistic Locking
1244
2
Data Flow and Caching
1246
1
Read to Write Ratios
1247
1
Object Caching
1248
3
Scalability Through Replication
1251
1
Server Replication and Clustering
1252
3
Project Planning for Good Performance and Scalability
1255
1
Summary
1256
3
Debugging Java Server Applications
1259
28
Differences of Java Server Programming
1260
10
The Java Language
1260
1
The Application Runs on the Server
1260
1
Long Running Processes
1261
3
Robustness and Stability
1264
2
Multi-User/Multi-Thread
1266
3
Performance
1269
1
Debugging Tools and Techniques
1270
15
Integrated Debuggers
1270
1
Do-It-Yourself, the JDB
1271
2
A Broader View
1273
1
Eyeballing
1273
1
System.out.println()
1274
5
Unit Testing
1279
1
Self-Made Monitoring Tools
1280
5
Summary
1285
2
Unit Testing J2EE Applications
1287
40
What is Unit Testing?
1288
2
What is a Unit?
1289
1
Introduction to the JUnit Framework
1290
1
Using the JUnit Framework
1290
2
How to Approach Unit Testing
1292
3
Steps of Unit Testing
1292
1
Writing Testable Code
1293
1
Why Unit Test?
1294
1
Unit Testing of Simple Objects
1295
13
Unit Testing a Utility Object
1295
7
Unit Testing a Business Object
1302
6
Unit Testing Servlets
1308
10
Unit Testing the Database Access Layer
1318
1
Unit Testing JSPs
1319
2
Unit Testing EJBs and RMI Objects
1321
4
Summary
1325
2
The Java Message Service
1327
34
Messaging Systems
1327
1
JMS Programming
1328
19
Publish and Subscribe Programming
1329
1
Connections and Sessions
1330
1
Topics
1331
1
Publishing a Message
1331
2
Subscribing to Topics
1333
1
Receiving Messages
1334
1
Unsubscribing From a Durable Subscription
1335
1
Point-to-Point Programming
1335
1
Sending Messages
1336
1
Receiving Messages
1336
1
Queue Browsing
1337
1
Messages
1338
1
Message Format
1338
1
Message Types
1338
1
Creating a Message
1338
2
JMS Programming Techniques and Issues
1340
1
Transactions
1340
1
Programmatic Message Acknowledgement
1341
1
Message Routing
1341
2
Messaging Reliability
1343
1
Using JMS to Transport XML
1343
2
Request-Reply Programming
1345
2
Using Queues to Load Balance Between Servers
1347
1
JMS Implementations
1347
1
A Sample Application
1348
7
Code Overview
1349
1
Initialization
1349
2
Input Loop
1351
2
Message Handler
1353
1
Running the Application
1354
1
Message-Based Integration with JMS
1355
4
JMS and XML as an Integration Platform
1355
1
Architectural Patterns for Integration
1356
2
Beyond Integration - Designing Open Applications
1358
1
Summary
1359
2
Integration with CORBA
1361
64
Tools Used in this Chapter
1362
1
CORBA Overview
1362
20
Object Location
1367
15
An IDL Primer
1382
5
Basic IDL Types
1382
1
Complex IDL Types
1382
1
Structures
1382
1
Enums
1383
1
Unions
1383
1
Arrays and Sequences
1383
1
Modules
1384
1
Interfaces
1384
1
Attributes
1384
1
Operations
1384
1
Exceptions
1385
1
Inheritance
1386
1
Multiple Inheritance
1387
1
J2EE and CORBA
1387
14
The WroxQuotes CORBA Object
1388
4
Writing the CORBA Object and Server
1392
4
Coding the CORBA Client
1396
3
Building and Running the Example
1399
2
Integration with J2EE
1401
22
Servlets and CORBA Objects
1401
5
Deploying and Running the Servlet
1406
4
JavaServer Pages and CORBA Objects
1410
4
Deploying and Running the JavaServer Page
1414
1
Enterprise JavaBeans and CORBA Objects
1414
4
Building the Enterprise JavaBean
1418
1
Deploying the Enterprise JavaBean
1418
1
Testing the Enterprise JavaBean
1419
3
J2EE as CORBA Clients Overview
1422
1
Summary
1423
2
Putting It All Together - J2EE Applications
1425
34
J2EE Applications
1425
7
J2EE Modules
1426
1
Web Applications
1426
1
EJB JARs
1426
1
Application Clients
1427
1
The alt-dd Element
1427
1
The Application Deployment Descriptor
1427
2
The Structure of a J2EE Application
1429
1
Enterprise Archive (EAR) Files
1429
1
The Application Assembler Role
1430
1
The Deployer Role
1430
1
Why J2EE Applications Matter
1430
1
Future Development of J2EE Applications
1431
1
Designing a J2EE Application
1432
1
The Application Development Lifecycle
1433
1
Building a Complete J2EE Application
1434
23
Requirements
1435
1
Design
1435
1
Implementing the Components
1436
1
EJB Module Implementation
1436
4
Web Module Implementation
1440
3
Component Packaging/Assembly
1443
1
Packaging the EJBs
1443
2
Packaging the Web Module
1445
1
Packaging the Swing Client
1445
1
Application Assembly
1446
1
Assembling the Application Using the Reference Implementation
1446
1
Assembling the Application Using Orion
1447
1
Manual Application Assembly
1448
2
Application Deployment
1450
1
Deploying in the J2EE Reference Implementation
1450
2
Deploying in Orion
1452
2
Running the Application
1454
1
Using Other Application Servers
1455
2
Summary
1457
2
Appendix A: Configuring Tomcat and JRun
1459
14
Tomcat Installation and Configuration
1459
5
Installing Tomcat
1459
1
server.xml
1460
1
web.xml
1461
1
Where to Put JSPs and Beans in a Web Application
1462
2
JRun 3.0 Installation and Configuration
1464
9
About JRun
1464
1
Obtaining JRun
1464
1
Installation
1464
2
Connecting to an External Web Server
1466
2
Where to Place Servlets, JSPs and Beans in a Web Application
1468
1
Creating an Application
1469
1
Under the Hood
1469
2
Enterprise JavaBeans
1471
1
Technical Support
1471
2
Appendix B: Setting Up Netscape's iPlanet Directory Server
1473
14
Installation
1474
8
Using Netscape Console
1482
5
Appendix C: HTTP Reference
1487
14
URL Request Protocols
1487
1
HTTP Basics
1488
6
Client Request
1488
1
HTTP Request Methods
1489
1
Server Response
1490
1
HTTP Headers
1491
3
Server Environment Variables
1494
7
Appendix D: Internationalization
1501
28
Character Sets
1502
3
Character Encodings
1503
1
Character Encoding Support in the Java Core API
1503
1
IANA Charset Names
1504
1
Content Negotiation
1505
5
Character Encoding Support in the Servlet API
1510
16
The Internationalization Servlet
1511
5
Returning a Variant of a Text File
1516
1
Server-Driven Content Negotiation
1516
1
Client-Driven Content Negotiation
1517
9
Summary
1526
3
Appendix E: Swing HTML Generation
1529
40
Problems with Servlets and JSP
1530
4
Emerging Options
1531
1
Which Solution?
1532
1
The HTML Generator Solution
1533
1
The Swing HTML Packages
1534
9
Creating a Java Object from an HTML File
1536
1
Handling HTML Form Items
1537
2
Accessing and Editing the Elements
1539
1
Setting Text Fields
1540
1
Setting Selects
1541
2
The Form Tag Hack
1543
3
A Simple HTML Generator
1546
12
The MiniParser Class
1546
7
The Helper Class
1553
5
A Servlet Example
1558
6
The Servlet
1560
3
Running the Servlet in Tomcat
1563
1
A JSP Example
1564
1
Problems and Development Potential
1565
1
Summary
1566
3
Appendix F: Support, Errata and P2P.Wrox. Com
1569
6
The Online Forums at P2P.Wrox.Com
1570
1
How to Enroll for Support
1570
1
Why This System Offers the Best Support
1570
1
Checking the Errata Online at www.wrox.com
1571
2
Wrox Developer's Membership
1571
1
Finding an Errata on the Web Site
1572
1
Add an Errata: E-mail Support
1573
1
Customer Support
1573
1
Editorial
1573
1
The Authors
1573
1
What We Can't Answer
1573
1
How to Tell Us Exactly What You Think
1573
2
A Guide to the Index
1575