Beginning Java EE 5 (eBook)
672 Seiten
Apress (Verlag)
978-1-4302-0084-0 (ISBN)
*Book covers all other neww J2EE-related technologies, like EJB 3, JSP 2.1, etc.
*Previous edition on 1.4 was excellent seller, with consistent low Amazon rank
Kevin Mukhar is a software developer in Colorado Springs, Colorado. For the past seven years, he has worked on various software systems using different Java Enterprise technologies. He has coauthored several books, including Beginning Java Databases and The Ultimate Palm Robot. In addition to developing software during the day, he is working on a master's degree in computer science. Learn more about him on his web page.
Sun's new lightweight Java Enterprise Edition (EE) 5 is an extremely powerful platform for developing enterprise-level Java-based applications, primarily for the server. This book shows you how to harness that power, examining how the pieces of the new Java EE 5 platform fit together, including the redesigned annotations-driven EJB 3 spec as well as JavaServer Faces (JSF), integrated into the platform for the first time. Hands-on tutorials are also included, along with clear explanations and working code examples. You will grow to take the next step from writing client-side desktop applications to writing enterprise applications. You will also learn how to use the individual APIs and tools in the Java EE 5 platform, and how to merge these to create your own enterprise applications.
Kevin Mukhar is a software developer in Colorado Springs, Colorado. For the past seven years, he has worked on various software systems using different Java Enterprise technologies. He has coauthored several books, including Beginning Java Databases and The Ultimate Palm Robot. In addition to developing software during the day, he is working on a master's degree in computer science. Learn more about him on his web page.
Contents 5
About the Authors 14
About the Technical Reviewer 15
Acknowledgments 16
Introduction 18
Chapter 1 Java EE Essentials 25
What Is Java EE? 26
How Java EE Relates to J2SE 26
Why Java EE? 26
Multitier Architecture 27
Single-Tier Systems 28
Client/Server (Two-Tier) Architecture 29
N-Tier Architecture 30
Vendor Independence 33
Scalability 34
Features and Concepts in Java EE 34
Java EE Clients and Servers 34
Containers 35
Java Servlets 37
JavaServer Pages (JSPs) 38
JavaServer Faces (JSF) 40
JDBC 41
EJBs 42
XML Support 45
Web Services 45
Transaction Support 46
Security 47
Sample Java EE Architectures 47
Application Client with EJB 47
JSP Client with EJB 48
Applet Client with JSP and Database 49
Web Services for Application Integration 49
Summary 50
Chapter 2 Getting Started 53
Installing JBoss 53
JBoss Installation Problems and Solutions 56
Testing the JBoss Installation 56
Starting the Server 56
JBoss Server Installation Problem and Solution 58
Compiling and Deploying a JSP Page 59
Creating the Example Application 59
Learning to Say “Hello” 62
Application Creation Problems and Solutions 65
Summary 65
Chapter 3 JavaServer Pages 67
Introduction to JSP 67
JSP Development 68
Basic JSP Lifecycle 68
JSP Elements 69
Directive Elements 70
Scripting Elements 72
Action Elements 74
Comments and Template Data 79
Creating and Deploying a JSP Web Application 79
Writing the JSP Web Application 79
Deploying the Web Application in Java EE 83
Deploying the Web Application in Tomcat 88
Handling Translation or Compilation Problems 92
Handling JSP Initialization and End of Life 95
JSP Scope 95
Using Implicit Objects 96
The request Object 97
The response Object 98
The out Object 98
The session Object 98
The config Object 99
The exception Object 100
The application Object 100
Using Standard Actions and Implicit Objects in JSP Pages 100
Translation and Compilation 109
Handling Errors and Exceptions 112
Dealing with Exceptions through the page Directive 112
Dealing with Exceptions in the Deployment Descriptor 113
Adding Exception Handling in JSP Pages 113
Including and Forwarding from JSP Pages 122
include Action 122
forward Action 123
Adding include and forward Actions to JSP Pages 124
Summary 128
Exercises 129
Chapter 4 Advanced JSP Topics 131
Expression Language 131
Scriptless JSPs 132
Syntax of EL Statements 134
Errors and Default Values in EL Statements 140
JSP Pages That Use EL 141
Custom Actions and Tag Handlers 150
How Custom Actions Work 151
Simple Tag Handlers 153
Classic Tag Handlers 164
A Multitude of Custom Actions 179
JSP Standard Tag Library (JSTL) 180
Getting a JSTL Implementation 180
Actions in the JSTL 180
Using the JSTL in a JSP 183
Summary 189
Exercises 190
Chapter 5 JavaServer Faces 191
Introduction to JSF 191
The Relationship Between JSF and Other Java EE Technologies 192
Request Processing Lifecycle 193
Installing JSF 195
Using JSF with JSP Pages 196
Creating a Simple JSF Application 197
Reviewing the JSF Lifecycle for the Sample Application 208
Using Managed Beans 208
Configuring Managed Beans 209
Using Value Binding Expressions in JSP Pages 213
Using Method Binding Expressions in JSP Pages 215
Expanding the JSF Sample Application 216
Controlling Page Navigation 226
Static and Dynamic Navigation 226
Navigation Rules 227
Adding Dynamic Navigation to the Sample JSF Application 228
Accessing Context Data in Beans 236
Converting Data 238
Using Standard Converters 239
Using Custom Converters 240
Validating Input 245
Using Standard Validators 245
Using Custom Validators 246
Bypassing Validation 248
Using Message Bundles 248
Summary 251
Exercises 252
Chapter 6 Servlets 253
HTTP and Server Programs 254
Request Methods 254
How a Server Responds to Requests 258
The Servlet Model and HttpServlets 258
Basic Servlet Design 259
A Servlet That Responds to POST Requests 262
The request Object 271
The response Object 274
Deployment Descriptors 274
Servlet Lifecycle 278
Event Logging in Servlets 282
Multithreading in Servlets 282
Exception Handling 290
Problems with Exception Handling 290
Error Pages 293
Session Management 294
Creating and Using Sessions 295
Using Cookies in Place of Sessions 303
Filters 304
Implementing the Filter Interface 305
Modifying the Deployment Descriptor to Use a Filter 306
The MVC Architecture 315
Model 1 vs. MVC 315
The Components of MVC 316
Servlet Chaining 317
Creating an MVC Application 319
Summary 330
Chapter 7 Working with Databases 332
Connecting to Databases 333
Using Data Sources for Connections 334
Configuring a DataSource and Connection with Java EE 334
Configuring a DataSource and Connection with Tomcat 344
Closing Connections 351
Setting the Login Timeout 353
Handling Exceptions 353
Logging with a DataSource 355
Creating and Using Statement Objects 356
Executing Single Statements 357
Performing Batch Updates 357
Releasing Statements 358
Using Statements to Insert Data into a Database 359
Using the ResultSet Class 367
Moving Through the ResultSet 367
Reading Data from Resultsets 370
Working with Null Values 374
Using Updatable Resultsets 374
Keeping the ResultSet Open: ResultSet Holdability 376
Summary 377
Exercises 377
Chapter 8 Advanced Topics in JDBC 379
Prepared Statements 379
Reasons for Using Prepared Statements 380
Creating a PreparedStatement 384
Using a Prepared Statement 385
Callable Statements 393
Reasons for Using Stored Procedures 393
Creating a CallableStatement 394
Calling a Stored Procedure 397
Transactions 398
Ending Transactions 398
Managing Transactions 399
Using Transactions with Stored Procedures 407
Using Distributed Transactions 408
Locking and Isolation 412
Setting Isolation Levels 413
Using Pessimistic and Optimistic Locking 414
Summary 424
Chapter 9 EJB Fundamentals and Session Beans 426
Understanding EJBs 426
Why Use EJBs? 427
The EJB Specification 428
The Three Kinds of EJBs 428
Which Type of EJB Should You Use? 431
The Anatomy of a Session Bean 432
Developing Session Beans 433
Using a Stateless Session Bean 433
Choosing Between Stateful and Stateless Session Beans 439
Using a Stateful Session Bean 440
Summary 445
Exercises 445
Chapter 10 EJB Entity Beans 446
How Entity Beans Work with Session Beans 446
The Anatomy of an Entity Bean 447
The Entity Bean Class 448
Container-Managed Persistence and the EntityManager Interface 449
Primary Keys 451
Bean-Managed Persistence 451
Developing CMP Entity Beans 452
Building the CMP Entity Bean Application 452
Compiling the CMP Entity Bean Application 459
Deploying the CMP Entity Bean Application 460
Running the CMP Entity Bean Application 460
Reviewing the CMP Entity Bean 461
Reviewing the Session Bean 461
Developing BMP Entity Beans 462
Building the BMP Entity Bean Application 463
Deploying the BMP Entity Bean Application 479
Running the BMP Entity Bean Application 480
Reviewing the BMP Entity Bean 480
The EJB Query Language 485
EJB QL Queries 486
Building and Deploying the EJB QL Queries Application 487
Running the EJB QL Queries Application 490
Reviewing the Session Bean Find Methods 491
Summary 492
Exercises 492
Chapter 11 EJB Relationships, EJB QL, and JDBC 494
Entity Bean Relationships 494
One-to-Many and Many-to-One Relationships 495
Many-to-Many Relationships 497
An EJB QL Query to Acquire a Subset of Data 498
Container-Managed Relationships and EJB QL 499
Building the Application with CMR 501
Compiling the CMR Application 512
Deploying the CMR Application 513
Loading the Database 513
Running the CMR Application 513
Reviewing the CMR Application 514
JDBC with EJB Entity Beans 517
Implementing JDBC with EJB Applications 518
Using JDBC with the StockList Bean 520
Summary 524
Exercises 524
Chapter 12 Design Patterns and EJB 525
Better by Design 525
Applying Design Patterns 526
Building the Application with Design Patterns 528
Compiling and Running the Application with Design Patterns 547
Reviewing the Application’s Design Patterns 549
Using JSP and Servlets with EJBs 552
Building the Modified JSP/Servlets Client 552
Reviewing the Modified JSP/Servlets Client 560
Summary 561
Exercises 561
Chapter 13 Message-Driven Beans 562
Message-Driven Beans Overview 562
Describing MDBs 564
The MDB Context 564
MDB Transactions 565
Invocation of an Interceptor 566
Java Message Service API 567
EJB Timer Service 568
Using MDBs, JMS, and the EJB Timer Service: Putting It All Together 569
Creating the MessageTimerApp Example 570
Building and Running MessageTimerApp 573
Reviewing MessageTimerApp 574
MessageTimerApp Summary 578
Summary 578
Exercises 579
Chapter 14 Web Services and JAX-WS 580
Understanding Web Services 581
Web Services Standards and Models 582
Why Use Web Services? 584
Web Services Protocol Stack 584
Developing a Web Service in Java 586
Introducing JAX-WS 587
Downloading the CVS Tool 588
Creating the Web Service 589
Building, Testing, and Serving the Web Service 595
Summary 597
Exercises 598
APPENDIX A Tomcat: Who Needs Java EE 5? 599
Obtaining and Installing Tomcat 599
Running Tomcat 602
APPENDIX B SQL and EJB QL 603
Introduction to SQL 603
Introduction to EJB QL 618
APPENDIX C Java EE Glossary 624
Index 631
Erscheint lt. Verlag | 2.11.2006 |
---|---|
Zusatzinfo | 672 p. |
Verlagsort | Berkeley |
Sprache | englisch |
Themenwelt | Informatik ► Programmiersprachen / -werkzeuge ► Java |
Mathematik / Informatik ► Informatik ► Web / Internet | |
Schlagworte | Annotation • EJB QL • Java • Java EE • JavaServer Faces • JavaServer Pages • JSP • Servlet • Web Services |
ISBN-10 | 1-4302-0084-7 / 1430200847 |
ISBN-13 | 978-1-4302-0084-0 / 9781430200840 |
Haben Sie eine Frage zum Produkt? |
Größe: 7,4 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich