𝔖 Scriptorium
✦   LIBER   ✦

📁

The J2EE Tutorial

✍ Scribed by Stephanie Bodoff, Dale Green, Kim Haase, Eric Jendrock, Monica Pawlan, Beth Stearns


Publisher
Addison-Wesley Professional
Year
2002
Tongue
English
Leaves
517
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Following in the footsteps of the The Java Tutorial -- a global best-seller -- The J2EE Tutorial offers an indispensable, example-centered resource for every developer who wants to master enterprise development with Java 2 Enterprise Edition, Version 1.3. The authors -- all of them Sun senior writers with direct access to the architects of the J2EE platform -- offer concise, hands-on introductions to each key J2EE technology. They offer practical techniques and examples for working with Enterprise JavaBeans, servlets, JavaServer Pages, Java Message Service (JMS), Java Naming and Directory Interface (JNDI), XML, the J2EE Connector Architecture, JavaMail, and JDBC. The book has been refined to reflect thousands of comments from developers utilizing draft editions published on the Web. All contents and examples are also provided on the accompanying CD-ROM, along with complete copies of the J2EE and J2SE Version 1.3 platform. For every experienced Java programmer who wants to build enterprise solutions with Java 2 Enterprise Edition Version 1.3.

✦ Table of Contents


Foreword......Page 17
Preface......Page 21
Table P–1 Prerequisite Topics......Page 22
3. Go to the j2eetutorial/examples directory.......Page 23
Table P–4 Other Tutorials......Page 24
2. Download the PDF version of this book from......Page 25
Table P–6 Typographical Conventions......Page 26
Overview......Page 27
Distributed Multitiered Applications......Page 28
J2EE Components......Page 29
J2EE Clients......Page 30
Business Components......Page 32
Container Services......Page 34
Container Types......Page 35
Packaging......Page 36
Development Roles......Page 37
Application Component Provider......Page 38
Application Assembler......Page 39
Reference Implementation Software......Page 40
J2EE APIs......Page 41
Simplified Systems Integration......Page 44
Tools......Page 45
Table 1–1 J2EE Scripts......Page 46
Getting Started......Page 47
Getting the Build Tool (ant)......Page 48
Starting the deploytool......Page 49
Coding the Enterprise Bean......Page 50
Packaging the Enterprise Bean......Page 52
3. General dialog box......Page 53
Coding the J2EE Application Client......Page 54
3. Retrieve the object bound to the name ejb/SimpleConverter.......Page 55
2. JAR File Contents dialog box......Page 57
Coding the Web Client......Page 58
2. WAR File dialog box......Page 60
Specifying the JNDI Names......Page 61
3. To specify a JNDI name for the bean, in the Application table locate the ConverterEJB componen.........Page 62
3. Set the APPCPATH environment variable to ConverterAppClient.jar.......Page 63
Running the Web Client......Page 64
5. In the Edit Search Paths dialog, specify the directories where the Update Files dialog will se.........Page 65
Cannot Start the J2EE Server......Page 66
Compilation Errors......Page 67
Deployment Errors......Page 68
J2EE Application Client Runtime Errors......Page 69
Web Client Runtime Errors......Page 70
When All Else Fails......Page 71
Enterprise Beans......Page 73
Benefits of Enterprise Beans......Page 74
What Is a Session Bean?......Page 75
State Management Modes......Page 76
What Is an Entity Bean?......Page 77
What Makes Entity Beans Different from Session Beans?......Page 78
Container-Managed Persistence......Page 79
What Is a Message-Driven Bean?......Page 82
When to Use Message-Driven Beans......Page 83
Remote Access......Page 84
Local Interfaces and Container-Managed Relationships......Page 85
Deciding on Remote or Local Access......Page 86
Method Parameters and Access......Page 87
Naming Conventions for Enterprise Beans......Page 88
The Life Cycle of a Stateful Session Bean......Page 89
The Life Cycle of a Stateless Session Bean......Page 90
The Life Cycle of an Entity Bean......Page 91
The Life Cycle of a Message-Driven Bean......Page 93
A Session Bean Example......Page 95
Session Bean Class......Page 96
2. The EJB container instantiates the enterprise bean.......Page 98
Home Interface......Page 100
2. In deploytool open the j2eetutorial/examples/ears/CartApp.ear file (FileÆOpen). You should see.........Page 102
3. Deploy the CartApp application (ToolsÆDeploy). In the Introduction dialog box, make sure that .........Page 103
Accessing Environment Entries......Page 104
Passing an Enterprise Bean’s Object Reference......Page 106
Bean-Managed Persistence Examples......Page 109
Entity Bean Class......Page 110
Home Interface......Page 120
Remote Interface......Page 122
Running the SavingsAccountEJB Example......Page 123
4. At the login prompts, enter guest for the user name and guest123 for the password.......Page 124
One-to-One Relationships......Page 125
2. Deploy the StorageBinApp.ear file (located in the j2eetutorial/examples/ears directory).......Page 128
One-to-Many Relationships......Page 129
2. Deploy the OrderApp.ear file (located in the j2eetutorial/examples/ears directory).......Page 132
Many-to-Many Relationships......Page 136
The Primary Key Class......Page 139
Primary Keys in the Entity Bean Class......Page 140
Getting the Primary Key......Page 141
Handling Exceptions......Page 142
Table 5–2 Exceptions......Page 143
Container-Managed Persistence Examples......Page 145
Overview of the RosterApp Application......Page 146
The PlayerEJB Code......Page 147
Table 6–1 Coding Differences between Persistent Types......Page 148
Local Home Interface......Page 152
Local Interface......Page 153
RosterApp......Page 154
RosterClient......Page 155
RosterJAR......Page 156
TeamJAR......Page 157
Method Invocations in RosterApp......Page 162
Creating a Player......Page 163
Adding a Player to a Team......Page 164
Removing a Player......Page 165
Dropping a Player from a Team......Page 166
Getting the Players of a Team......Page 167
Getting a Copy of a Team’s Players......Page 168
Finding the Players by Position......Page 170
Getting the Sports of a Player......Page 171
2. Deploy the application.......Page 173
3. In the General dialog box, specify the local interfaces of the entity bean. (If the bean also .........Page 174
2. With container-managed persistence, the container can automatically create or delete the datab.........Page 175
3. To add or edit a relationship, go the Relationships tab and click the appropriate button.......Page 176
The Primary Key Class......Page 177
Primary Keys in the Entity Bean Class......Page 178
Generating Primary Key Values......Page 179
A Message-Driven Bean Example......Page 181
Example Application Overview......Page 182
The Message-Driven Bean Class......Page 183
The onMessage Method......Page 184
Deploying the Application......Page 185
deploytool Tips for Message-Driven Beans......Page 186
4. If you’ve specified bean-managed transactions, then you may select the acknowledgment type—eit.........Page 187
Setting the Resource References......Page 188
Specifying the JNDI Names......Page 189
Table 7–1 JNDI Names for the SimpleMessageApp Application......Page 190
Enterprise JavaBeans Query Language......Page 191
Terminology......Page 192
Simple Finder Queries......Page 193
Finder Queries That Navigate to Related Beans......Page 195
Finder Queries with Other Conditional Expressions......Page 196
Select Queries......Page 198
BNF Grammar of EJB QL......Page 199
FROM Clause......Page 202
Path Expressions......Page 205
WHERE Clause......Page 208
Table 8–2 EJB QL Operator Precedence......Page 210
Table 8–3 LIKE Expression Examples......Page 212
Table 8–5 Arithmetic Expressions......Page 213
Table 8–7 OR Operator Logic......Page 214
Table 8–9 Conditional Test......Page 215
SELECT Clause......Page 216
EJB QL Restrictions......Page 217
Web Clients and Components......Page 219
Web Client Life Cycle......Page 220
3. Deploy the application.......Page 221
Web Application Archives......Page 222
3. Navigate to the directory containing the WAR file, select the WAR file, and click Add Web WAR.......Page 223
3. Create the WAR file and add the GreetingServlet Web component and all of the Hello1App applica.........Page 224
Application-Level Configuration......Page 225
2. Select the Event Listeners tab.......Page 226
3. Add a filter.......Page 227
2. Select the Init. Parameters tab.......Page 228
Running Web Clients......Page 229
6. Deploy Hello2App.......Page 230
5. A dialog box appears reporting the changed file.Verify that response.jsp has been changed and .........Page 231
Internationalizing Web Clients......Page 232
Java Servlet Technology......Page 235
What Is a Servlet?......Page 236
Table10–1 Duke’s Bookstore Example Servlets......Page 237
7. Create the WAR and add the BannerServlet Web component and all of the Duke’s Bookstore content.........Page 238
10. Add the listener class listeners.ContextListener (described in Handling Servlet Life-Cycle Ev.........Page 239
14. Deploy the application.......Page 240
Troubleshooting......Page 241
Handling Servlet Life-Cycle Events......Page 242
Table10–3 Servlet Life-Cycle Events......Page 243
Sharing Information......Page 244
Table10–4 Scope Objects......Page 245
Controlling Concurrent Access to Shared Resources......Page 246
Accessing Databases......Page 247
Writing Service Methods......Page 248
Getting Information from Requests......Page 249
Table10–6 Request Path Elements......Page 250
Constructing Responses......Page 251
Filtering Requests and Responses......Page 253
Programming Filters......Page 255
Programming Customized Requests and Responses......Page 256
Specifying Filter Mappings......Page 258
Table10–7 Duke’s Bookstore Filter Mapping List......Page 259
Including Other Resources in the Response......Page 260
Transferring Control to Another Web Component......Page 262
Accessing the Web Context......Page 263
Associating Attributes with a Session......Page 264
2. Select the General tab.......Page 265
Session Tracking......Page 266
Finalizing a Servlet......Page 267
Notifying Methods to Shut Down......Page 268
Creating Polite Long-Running Methods......Page 269
JavaServer Pages Technology......Page 271
What Is a JSP Page?......Page 272
5. Deploy the application.......Page 274
Table 11–1 Duke’s Bookstore Example JSP Pages......Page 275
8. Add the BookDBEJB enterprise bean to the application.......Page 277
12. Specify the JNDI Names.......Page 278
Translation and Compilation......Page 279
Execution......Page 280
Initializing and Finalizing a JSP Page......Page 282
Creating Dynamic Content......Page 283
Table 11–2 Implicit Objects......Page 284
JSP Scripting Elements......Page 286
Including Content in a JSP Page......Page 289
Including an Applet......Page 291
Extending the JSP Language......Page 293
JavaBeans Components in JSP Pages......Page 295
JavaBeans Component Design Conventions......Page 296
Why Use a JavaBeans Component?......Page 297
Creating and Using a JavaBeans Component......Page 298
Table 12–1 Setting JavaBeans Component Properties......Page 299
Table 12–2 Valid Value Assignments......Page 300
Retrieving JavaBeans Component Properties......Page 301
Custom Tags in JSP Pages......Page 305
What Is a Custom Tag?......Page 306
The Example JSP Pages......Page 307
2. Download and unpack Struts version 1.0 from......Page 308
8. Create the WAR and add the DispatcherServlet Web component and all of the Duke’s Bookstore con.........Page 309
12. Specify the JNDI names.......Page 310
Declaring Tag Libraries......Page 311
Types of Tags......Page 312
Tag Handlers......Page 315
Tag Library Descriptors......Page 316
Table 13–2 taglib Subelements......Page 317
Table 13–3 tag Subelements......Page 318
Simple Tags......Page 319
Tags with Attributes......Page 320
Tags With Bodies......Page 322
Tags That Define Scripting Variables......Page 324
Table 13–4 Scope of Objects......Page 325
Table 13–5 Scripting Variable Availability......Page 327
Cooperating Tags......Page 328
An Iteration Tag......Page 330
A Template Tag Library......Page 334
Table 13–6 Screen Definitions......Page 337
Table 13–7 Screen Definition for the URL /enter......Page 338
How Is a Tag Handler Invoked?......Page 339
Transactions......Page 341
Container-Managed Transactions......Page 342
Transaction Attributes......Page 343
3. Delegates the call to the method......Page 344
Table 14–1 Transaction Attributes and Scope......Page 346
Rolling Back a Container-Managed Transaction......Page 347
Synchronizing a Session Bean’s Instance Variables......Page 348
Bean-Managed Transactions......Page 349
JDBC Transactions......Page 350
JTA Transactions......Page 351
Returning without Committing......Page 352
Table 14–2 Allowed Transaction Types for Enterprise Beans......Page 353
Isolation Levels......Page 354
Updating Multiple Databases......Page 355
Transactions in Web Components......Page 357
Security......Page 359
Overview......Page 360
Declaring and Linking Role References......Page 361
7. In the Description dialog box, enter a description.......Page 362
Protecting Web Resources......Page 363
Authenticating Users of Web Resources......Page 364
3. Choose one of the following authentication mechanisms from the User Authentication Method pull.........Page 365
EJB-Tier Security......Page 366
Using Programmatic Security in the EJB Tier......Page 367
Application Client-Tier Security......Page 368
EIS-Tier Security......Page 369
Component-Managed Sign-On......Page 370
4. In the Security Permissions pane, click the Add button to add a security permission that your .........Page 371
Configuring a Component’s Propagated Security Identity......Page 372
5. In the Client Authentication pane, select Certificate as the method by which the server expect.........Page 373
J2EE Users, Realms, and Groups......Page 374
2. From the Groups window, select the group to remove.......Page 375
2. The keytool utility prompts you for the following information:......Page 376
4. If you want to have your certificate digitally signed by a CA, do the following:......Page 377
Resource Connections......Page 379
3. Click Add.......Page 380
6. In the Authentication combo box, select Container.......Page 381
4. In the row you just selected, enter the JNDI name. For the SavingsAccountEJB example, you woul.........Page 382
2. Obtain the DataSource associated with the logical name.......Page 383
Mail Session Connections......Page 385
4. At the login prompts, enter guest for the user name and guest123 for the password.......Page 387
URL Connections......Page 388
3. Type the following command on a single line:......Page 389
4. At the login prompts, enter guest for the user name and guest123 for the password.......Page 390
J2EE Connector Architecture......Page 391
Resource Adapter Contracts......Page 392
Administering Resource Adapters......Page 394
Table17–1 Black Box Transaction Levels......Page 395
Table17–3 Default Values for Black Box Properties......Page 396
2. Edit the bin/userconfig.sh (UNIX) or bin\userconfig.bat (Windows) file, setting the J2EE_CLASS.........Page 397
2. Add a connection factory for the resource adapter. The JNDI name for the connection factory is.........Page 398
5. Replace the new SavingsAccountBean.class file in the existing SavingsAccountApp.ear file.......Page 399
8. Deploy the SavingsAccountApp application.......Page 400
Overview of the CCI......Page 401
Programming with the CCI......Page 402
2. Use the JNDI InitialContext.lookup method to find the user and password values.......Page 404
6. Invoke the createIndexedRecord method of RecordFactory. This method creates a new IndexedRecor.........Page 409
9. Retrieve each element in the returned record object using the iterator.hasNext method. Each ex.........Page 410
Writing a CCI Client......Page 411
2. Next, add a connection factory for the deployed CCI adapter. The connection factory supplies a.........Page 412
2. Select the Resource Refs tab of the CoffeeBean component and note the following (Figure 17–3).......Page 414
4. Run the client by typing the following on one line.......Page 415
5. At the login prompts, enter guest as the user name and guest123 as the password.......Page 416
The Duke’s Bank Application......Page 417
Enterprise Beans......Page 419
Session Beans......Page 420
Helper Classes......Page 423
Database Tables......Page 424
Application Client......Page 426
The Classes and Their Relationships......Page 427
BankAdmin Class......Page 429
EventHandle Class......Page 430
DataModel Class......Page 431
Table 18–2 Web Client......Page 434
Design Strategies......Page 435
Web Client Life Cycle......Page 436
2. Creates a JavaBeans component and stores the bean as a request attribute.......Page 438
4. Calls the populate method of the JavaBeans component. This method retrieves data from the ente.........Page 439
Internationalization......Page 440
Adding Groups and Users to the Realm......Page 442
Starting the J2EE Server, deploytool, and Database......Page 443
Packaging the Enterprise Beans......Page 444
Packaging the J2EE Application Client......Page 445
Reviewing JNDI Names......Page 446
3. Select the checkbox labeled Return Client Jar. By default, the directory for the returned JAR .........Page 449
3. To run the English version of the client, execute the following command:......Page 450
2. The application will display the login page. Enter 200 for the customer ID and j2ee for the pa.........Page 451
3. Select an application function: Account List, Transfer Funds, ATM, or Logoff. Once you have a .........Page 452
HTTP Overview......Page 453
HTTP Responses......Page 454
J2EE SDK Tools......Page 455
Table B–1 j2eeadmin Options......Page 456
Cloudscape Server......Page 457
Running the Interactive SQL Tool......Page 458
Cloudscape Server Configuration......Page 459
Table B–2 deploytool Options......Page 460
Key Tool......Page 461
EJB JAR File......Page 462
Application Client JAR File......Page 463
Specifying the Runtime Deployment Descriptor......Page 464
Resource Adapter RAR File......Page 465
Examples......Page 466
Table B–5 runclient Options......Page 467
4. Set the APPCPATH environment variable to the name of the client JAR stub file.......Page 468
Table B–6 verifier Options......Page 469
4. Click OK.......Page 470
Table C–1 Examples......Page 471
Glossary......Page 475
About the Authors......Page 499
Index......Page 501


📜 SIMILAR VOLUMES


The J2EE Tutorial
✍ Stephanie Bodoff, Eric Armstrong, Jennifer Ball, Debbie Carson, Ian Evans, Dale 📂 Library 📅 2004 🏛 Prentice Hall PTR 🌐 English

This is the complete guide to all major components of the Java 2 Platform, Enterprise Edition (J2EE) version 1.4. Written by members of the J2EE platform team at Sun Microsystems, this is the task-oriented and example-driven book that will have new and intermediate Java programmers building J2EE app

The J2EE Tutorial
✍ Stephanie Bodoff, Dale Green, Kim Haase, Eric Jendrock, Monica Pawlan, Beth Stea 📂 Library 📅 2002 🏛 Addison-Wesley Professional 🌐 English

* Gentle, self-paced introductions to servlets, JSP, JDBC, EJBs, XML, JMS, JNDI, and many other key topics. * Follows the same approach and format that made The JavaTTM Tutorial a worldwide best-seller! * Includes CD-ROM containing all content, examples, and both the J2EE and J2SE Version 1.3 softwa

The J2EE 1.4 Tutorial
✍ E. Armstrong et al. 📂 Library 📅 2006 🏛 Sun Microsystems 🌐 English

When the first edition of The J2EE™ Tutorial was released, the Java™ 2 Plat- form, Enterprise Edition (J2EE) was the new kid on the block. Modeled after its forerunner, the Java 2 Platform, Standard Edition (J2SE™), the J2EE platform brought the benefits of “Write Once, Run Anywhere™” API compatibi

J2EE
✍ Jerome Moliere 📂 Library 🌐 French