The J2EE Tutorial

Front Cover
Addison-Wesley Professional, 2002 - Computers - 491 pages
You're familiar with Java(TM) programming, but now it's time for you to take it to the next level and begin creating enterprise applications with the Java(TM) 2 Platform, Enterprise Edition (J2EE(TM) ). "The J2EE(TM) Tutorial is the hands-on, example-driven guide that offers unparalleled technical guidance into developing and deploying applications on the J2EE platform.

Written by the uniquely qualified members of the Java Software team at Sun Microsystems, "The J2EE(TM) Tutorial uses the same effective interactive approach as the successful Java(TM) Tutorial collection. Throughout this book's development, hundreds of suggestions and volumes of feedback from both users and architects were integrated to ensure great writing and truly useful guidance.

Inside you'll find a smart mix of example programs--including source code--that are used to illustrate key J2EE concepts. In addition, clear explanations will help you make easy work of the range of technologies collected into the J2EE platform, including: Enterprise JavaBeans(TM) Java(TM) ServletsJavaServer Pages(TM) Java(TM) Message Service (JMS)Java Naming and Directory Interface(TM) (JNDI)XMLJ2EE(TM) Connector ArchitectureJavaMail(TM) JDBC(TM)

When you're ready to create your own great enterprise applications, turn to the unmatched guidance, understanding, and experience you'll find only in "The J2EE(TM) Tutorial.

The accompanying CD-ROM is filled with a wealth of valuable resources, including all three Java(TM) Tutorial books, the J2SE 1.3.1 and J2EE 1.3.1 software development kits, the Java BluePrints sample application and book, and Forte for Java Plugin for the J2EE SDK.
0201791684B03012002

 

Selected pages

Contents

Overview
1
Distributed Multitiered Applications
2
J2EE Components
3
J2EE Clients
4
Web Components
6
Enterprise Information System Tier
8
Container Types
9
Packaging
10
Filtering Requests and Responses
227
Programming Filters
229
Programming Customized Requests and Responses
230
Specifying Filter Mappings
232
Invoking Other Web Resources
234
Transferring Control to Another Web Component
236
Accessing the Web Context
237
Maintaining Client State
238

Development Roles
11
J2EE Product Provider
12
Application Assembler
13
Application Deployer and Administrator
14
Database Access
15
Simplified Systems Integration
18
Tools
19
Getting Started
21
Setting Up
22
Checking the Environment Variables
23
Creating the J2EE Application
24
Compiling the Source Files
26
Creating the J2EE Application Client
28
Compiling the Application Client
31
Specifying the Application Clients Enterprise Bean Reference
32
Compiling the Web Client
34
Specifying the Web Clients Enterprise Bean Reference
35
Deploying the J2EE Application
37
Running the Web Client
38
Modifying the J2EE Application
39
Adding a File
40
Compilation Errors
41
Deployment Errors
42
J2EE Application Client Runtime Errors
43
Web Client Runtime Errors
44
Detecting Problems With the Verifier Tool
45
Enterprise Beans
47
What Is an Enterprise Bean?
48
When to Use Enterprise Beans
49
State Management Modes
50
When to Use Session Beans
51
What Makes Entity Beans Different from Session Beans?
52
ContainerManaged Persistence
53
When to Use Entity Beans
56
What Makes MessageDriven Beans Different from Session and Entity Beans?
57
Defining Client Access with Interfaces
58
Local Access
59
Deciding on Remote or Local Access
60
Performance and Access
61
The Contents of an Enterprise Bean
62
The Life Cycles of Enterprise Beans
63
The Life Cycle of a Stateless Session Bean
64
The Life Cycle of an Entity Bean
65
The Life Cycle of a MessageDriven Bean
67
A Session Bean Example
69
The CartEJB Example
70
Home Interface
74
Remote Interface
76
Other Enterprise Bean Features
78
Comparing Enterprise Beans
80
BeanManaged Persistence Examples
83
The SavingsAccountEJB Example
84
Home Interface
94
Remote Interface
96
Running the SavingsAccountEJB Example Setting Up the Database
97
deploytool Tips for Entity Beans with BeanManaged Persistence
99
OnetoMany Relationships
103
ManytoMany Relationships
110
Primary Keys for BeanManaged Persistence
113
Primary Keys in the Entity Bean Class
114
Getting the Primary Key
115
Handling Exceptions
116
ContainerManaged Persistence Examples
119
Overview of the RosterApp Application
120
The PlayerEJB Code
121
Entity Bean Class
122
Local Home Interface
126
Local Interface
127
A Guided Tour of the RosterApp Settings
128
RosterClient
129
RosterJAR
130
TeamJAR
131
MethodInvocations in RosterApp
136
Creating a Player
137
Adding a Player to a Team
138
Removing a Player
139
Dropping a Player from a Team
140
Getting the Players of a Team
141
Getting a Copy of a Teams Players
142
Finding the Players by Position
144
Getting the Sports of a Player
145
Running the RosterApp Example
147
Running the Client
148
the Persistent Fields and Abstract Schema Name
149
Specifying the Database JNDl Name User Name and Password
150
Primary Keys for ContainerManaged Persistence
151
Primary Keys in the Entity Bean Class
152
Generating Primary Key Values
153
A MessageDriven Bean Example
155
Example Application Overview
156
The J2EE Application Client
157
The onMessage Method
158
The ejbCreate and ejbRemove Methods
159
Running the Client
160
Specifying the Beans Type and Transaction Management
161
deploytool Tips for JMS Clients
162
Setting the Resource Environment References
163
Enterprise JavaBeans Query Language
165
Terminology
166
Simplified Syntax
167
Finder Queries That Navigate to Related Beans
169
Finder Queries with Other Conditional Expressions
170
Select Queries
172
Full Syntax
173
FROM Clause
176
Path Expressions
179
WHERE Clause
182
SELECT Clause
190
EJB QL Restrictions
191
Web Clients and Components
193
Web Client Life Cycle
194
Web Application Archives
196
Creating a WAR File
197
Adding a Web Component to a WAR File
198
Configuring Web Clients
199
WARLevel Configuration
200
ComponentLevel Configuration Initialization Parameters
202
Deploying Web Clients
203
Updating Web Clients
204
Internationalizing Web Clients
206
Java Servlet Technology
209
What Is a Servlet?
210
The Example Servlets
211
Troubleshooting
215
Servlet Life Cycle
216
Handling Errors
218
Using Scope Objects
219
Controlling Concurrent Access to Shared Resources
220
Accessing Databases
221
Initializing a Servlet
222
Getting Information from Requests
223
Constructing Responses
225
Session Management
239
Session Tracking
240
Finalizing a Servlet
241
Tracking Service Requests
242
Creating Polite LongRunning Methods
243
JavaServer Pages Technology
245
What Is a JSP Page?
246
The Example JSP Pages
249
The Life Cycle of a JSP Page
253
Execution
254
Initializing and Finalizing a JSP Page
256
Creating Static Content
257
Using Objects within JSP Pages
258
JSP Scripting Elements
260
Including Content in a JSP Page
263
Transferring Control to Another Web Component
265
Extending the JSP Language
267
JavaBeans Components in JSP Pages
269
JavaBeans Component Design Conventions
270
Why Use a JavaBeans Component?
271
Creating and Using a JavaBeans Component
272
Setting JavaBeans Component Properties
273
Retrieving JavaBeans Component Properties
275
Custom Tags in JSP Pages
279
What Is a Custom Tag?
280
The Example JSP Pages
281
Using Tags
285
Types of Tags
286
Defining Tags
289
Tag Library Descriptors
290
Simple Tags
293
Tags with Attributes
294
Tags With Bodies
296
Tags That Define Scripting Variables
298
Cooperating Tags
302
Examples
304
A Template Tag Library
308
How Is a Tag Handler Invoked?
313
Transactions
315
What Is a Transaction?
316
Transaction Attributes
317
Rolling Back a ContainerManaged Transaction
321
Synchronizing a Session Beans Instance Variables
322
Methods Not Allowed in ContainerManaged Transactions
323
JDBC Transactions
324
JTA Transactions
325
Returning without Committing
326
Methods Not Allowed in BeanManaged Transactions
327
Transaction Timeouts
328
Updating Multiple Databases
329
Transactions in Web Components
331
Security
333
Overview
334
Security Roles
335
Mapping Roles to J2EE Users and Groups
337
Controlling Access to Web Resources
338
Using Programmatic Security in the Web Tier
340
Declaring Method Permissions
341
Unprotected EJBTier Resources
342
Specifying the Application Clients Callback Handler
343
Configuring SignOn
344
Configuring Resource Adapter Security
345
Propagating Security Identity
346
Configuring Client Authentication
347
J2EE Users Realms and Groups
348
Managing J2EE Users and Groups
349
Setting Up a Server Certificate
350
Resource Connections
353
JNDI Names and Resource References
354
Database Connections for Enterprise Beans
357
Connection Pooling
359
Running the ConfirmerEJB Example
361
URL Connections
362
Running the HTMLReaderEJB Example
363
J2EE Connector Architecture
365
About Resource Adapters
366
Administering Resource Adapters
368
The Black Box Resource Adapters
369
Properties
370
Configuring JDBC Drivers
371
Resource Adapter Tutorial
372
Testing the Resource Adapter
373
Common Client Interface
375
Programming with the CCI
376
Writing a CCI Client
385
CCI Tutorial
386
The Dukes Bank Application
391
Enterprise Beans
393
Session Beans
394
Entity Beans
397
Database Tables
398
Protecting the Enterprise Beans
400
The Classes and Their Relationships
401
BankAdmin Class
403
EventHandle Class
404
DataModel Class
405
Web Client
408
Design Strategies
409
Web Client Life Cycle
410
Protecting the Web Resources
414
Building Packaging Deploying and Running the Application
416
Starting the J2EE Server deploytool and Database J2EE Server
417
Compiling the Enterprise Beans
418
Compiling the Web Client
419
Packaging the Enterprise Archive File
420
Mapping the Security Roles to Groups
423
Creating the Bank Database
424
Running the Web Client
425
HTTP Overview
427
HTTP Requests
428
J2EE SDK Tools
429
J2EE Administration Tool
430
Cleanup Tool
431
Starting Cloudscape
432
Cloudscape Server Configuration
433
Deployment Tool
434
J2EE Server
435
Packager Tool
436
Web Application WAR File Syntax
437
J2EE Application EAR File Syntax
438
Resource Adapter RAR File Syntax
439
Realm Tool
440
runclient Script
441
Example
442
Preventing the User Name and Password Prompts
443
StandAlone GUI Verifier
444
Examples
445
Glossary
449
About the Authors
473
Index
475
Copyright

Other editions - View all

Common terms and phrases

Bibliographic information