Home > Store

Java EE 7 Tutorial, The: Volume 1, 5th Edition

eBook (Watermarked)

  • Your Price: $31.99
  • List Price: $39.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Also available in other formats.

Register your product to gain access to bonus material or receive a coupon.


  • Copyright 2014
  • Dimensions: 7-1/2" x 9-1/8"
  • Pages: 696
  • Edition: 5th
  • eBook (Watermarked)
  • ISBN-10: 0-13-390161-0
  • ISBN-13: 978-0-13-390161-0

The Java EE 7 Tutorial: Volume 1, Fifth Edition, is a task-oriented, example-driven guide to developing enterprise applications for the Java Platform, Enterprise Edition 7 (Java EE 7). Written by members of the Java EE documentation team at Oracle, this book provides new and intermediate Java programmers with a deep understanding of the platform.

This guide includes descriptions of platform features and provides instructions for using the latest versions of NetBeans IDE and GlassFish Server Open Source Edition. The book introduces platform basics, including resource creation, resource injection, and packaging. It covers JavaServer Faces, Java Servlets, the Java API for WebSocket, the Java API for JSON Processing (JSON-P), internationalization and localization, Bean Validation, Contexts and Dependency Injection for Java EE (CDI), and web services (JAX-WS and JAX-RS).

Sample Content

Table of Contents

Preface                         xxix

Part I: Introduction            1

Chapter 1: Overview            3

1.1   Java EE 7 Platform Highlights    4

1.2   Java EE Application Model   5

1.3   Distributed Multitiered Applications   6

1.4   Java EE Containers    13

1.5   Web Services Support    15

1.6   Java EE Application Assembly and Deployment    17

1.7   Development Roles    17

1.8   Java EE 7 APIs    20

1.9   Java EE 7 APIs in the Java Platform, Standard Edition 7    30

1.10 GlassFish Server Tools    33

Chapter 2: Using the Tutorial Examples            35

2.1   Required Software    35

2.2   Starting and Stopping GlassFish Server    39

2.3   Starting the Administration Console.    40

2.4   Starting and Stopping the Java DB Server   40

2.5   Building the Examples    41

2.6   Tutorial Example Directory Structure    41

2.7   Java EE 7 Maven Archetypes in the Tutorial    42

2.8   Getting the Latest Updates to the Tutorial    43

2.9   Debugging Java EE Applications    44

Part II: Platform Basics                       47

Chapter 3: Resource Creation            49

3.1   Resources and JNDI Naming    49

3.2   DataSource Objects and Connection Pools     50

3.3   Creating Resources Administratively    51

Chapter 4: Injection            53

4.1   Resource Injection    53

4.2   Dependency Injection     54

4.3   The Main Differences between Resource Injection and Dependency Injection     55

Chapter 5: Packaging            57

5.1   Packaging Applications     57

5.2   Packaging Enterprise Beans    59

5.3   Packaging Web Archives    61

5.4   Packaging Resource Adapter Archives    63

Part III: The Web Tier                                             65

Chapter 6: Getting Started with Web Applications            67

6.1   Web Applications    68

6.2   Web Application Lifecycle    69

6.3   A Web Module That Uses JavaServer Faces Technology: The hello1 Example    70

6.4   A Web Module That Uses Java Servlet Technology: The hello2 Example      77

6.5   Configuring Web Applications     81

6.6   Further Information about Web Applications    86

Chapter 7: JavaServer Faces Technology                                   87

7.1   What Is a JavaServer Faces Application?    88

7.2   JavaServer Faces Technology Benefits    89

7.3   A Simple JavaServer Faces Application     91

7.4   User Interface Component Model   92

7.5   Navigation Model    100

7.6   The Lifecycle of a JavaServer Faces Application     103

7.7   Partial Processing and Partial Rendering     110

7.8   Further Information about JavaServer Faces Technology     110

Chapter 8: Introduction to Facelets     111

8.1   What Is Facelets?     112

8.2   The Lifecycle of a Facelets Application     114

8.3   Developing a Simple Facelets Application: The guessnumber-jsf Example Application     115

8.4   Using Facelets Templates     121

8.5   Composite Components     124

8.6   Web Resources     127

8.7   Relocatable Resources     128

8.8   Resource Library Contracts     128

8.9   HTML5-Friendly Markup     132

Chapter 9: Expression Language                   141

9.1   Overview of the EL    141

9.2   Immediate and Deferred Evaluation Syntax    142

9.3   Value and Method Expressions     144

9.4   Operations on Collection Objects    151

9.5   Operators    153

9.6   Reserved Words     154

9.7   Examples of EL Expressions    154

9.8   Further Information about the Expression Language     155

Chapter 10: Using JavaServer Faces Technology in Web Pages     157

10.1   Setting Up a Page    158

10.2   Adding Components to a Page Using HTML Tag Library Tags    159

10.3   Using Core Tags     192

Chapter 11:   Using Converters, Listeners, and Validators           197

11.1   Using the Standard Converters     198

11.2   Registering Listeners on Components     203

11.3   Using the Standard Validators     207

11.4   Referencing a Managed Bean Method     209

Chapter 12:   Developing with JavaServer Faces Technology                    213

12.1   Managed Beans in JavaServer Faces Technology      213

12.2   Writing Bean Properties     216

12.3   Writing Managed Bean Methods     226

Chapter 13: Using Ajax with JavaServer Faces Technology     231

13.1   Overview of Ajax    232

13.2   Using Ajax Functionality with JavaServer Faces Technology    233

13.3   Using Ajax with Facelets     233

13.4   Sending an Ajax Request     236

13.5   Monitoring Events on the Client     238

13.6   Handling Errors    238

13.7   Receiving an Ajax Response    239

13.8   Ajax Request Lifecycle    240

13.9   Grouping of Components    240

13.10  Loading JavaScript as a Resource     241

13.11  The ajaxguessnumber Example Application     243

13.12  Further Information about Ajax in JavaServer Faces Technology    247

Chapter 14: Composite Components: Advanced Topics and an Example             249

14.1   Attributes of a Composite Component    249

14.2   Invoking a Managed Bean     251

14.3   Validating Composite Component Values     251

14.4   The compositecomponentexample Example Application     251

Chapter 15: Creating Custom UI Components and Other Custom Objects               257

15.1   Determining Whether You Need a Custom Component or Renderer     259

15.2   Understanding the Image Map Example      262

15.3   Steps for Creating a Custom Component     268

15.4   Creating Custom Component Classes    268

15.5   Delegating Rendering to a Renderer    278

15.6   Implementing an Event Listener    281

15.7   Handling Events for Custom Components    283

15.8   Defining the Custom Component Tag in a Tag Library Descriptor     284

15.9   Using a Custom Component    285

15.10 Creating and Using a Custom Converter    287

15.11 Creating and Using a Custom Validator    292

15.12 Binding Component Values and Instances to Managed Bean Properties    298

15.13 Binding Converters, Listeners, and Validators to Managed Bean Properties     303

Chapter 16: Configuring JavaServer Faces Applications           305

16.1   Using Annotations to Configure Managed Beans    306

16.2   Application Configuration Resource File    307

16.3   Using Faces Flows     311

16.4   Configuring Managed Beans    323

16.5   Registering Application Messages     332

16.6   Using Default Validators    335

16.7   Registering a Custom Validator   336

16.8   Registering a Custom Converter    337

16.9   Configuring Navigation Rules     337

16.10 Registering a Custom Renderer with a Render Kit    340

16.11 Registering a Custom Component    342

16.12 Basic Requirements of a JavaServer Faces Application    343

Chapter 17: Java Servlet Technology           351

17.1   What Is a Servlet?    352

17.2   Servlet Lifecycle    352

17.3   Sharing Information    354

17.4   Creating and Initializing a Servlet    356

17.5   Writing Service Methods    356

17.6   Filtering Requests and Responses    359

17.7   Invoking Other Web Resources    363

17.8   Accessing the Web Context    365

17.9   Maintaining Client State    365

17.10 Finalizing a Servlet    367

17.11 Uploading Files with Java Servlet Technology    370

17.12 Asynchronous Processing    372

17.13 Nonblocking I/O    375

17.14 Protocol Upgrade Processing    378

17.15 The mood Example Application    381

17.16 The fileupload Example Application    383

17.17 The dukeetf Example Application    388

17.18 Further Information about Java Servlet Technology    394

Chapter 18: Java API for WebSocket           395

18.1   Introduction to WebSocket    396

18.2   Creating WebSocket Applications in the Java EE Platform    397

18.3   Programmatic Endpoints    398

18.4   Annotated Endpoints    399

18.5   Sending and Receiving Messages    400

18.6   Maintaining Client State    402

18.7   Using Encoders and Decoders   403

18.8   Path Parameters    406

18.9   Handling Errors    407

18.10 Specifying an Endpoint Configurator Class    407

18.11 The dukeetf2 Example Application    408

18.12 The websocketbot Example Application   413

18.13 Further Information about WebSocket    420

Chapter 19: JSON Processing            421

19.1   Introduction to JSON    421

19.2   JSON Processing in the Java EE Platform    423

19.3   Using the Object Model API    425

19.4   Using the Streaming API    429

19.5   JSON in Java EE RESTful Web Services   431

19.6   The jsonpmodel Example Application    432

19.7   The jsonpstreaming Example Application    434

19.8   Further Information about the Java API for JSON Processing    436

Chapter 20: Internationalizing and Localizing Web Applications            437

20.1   Java Platform Localization Classes    437

20.2   Providing Localized Messages and Labels   438

20.3   Date and Number Formatting    441

20.4   Character Sets and Encodings    442

Part IV: Bean Validation              445

Chapter 21: Introduction to Bean Validation    447

21.1   Using Bean Validation Constraints   447

21.2   Validating Null and Empty Strings    450

21.3   Validating Constructors and Methods    451

21.4   Further Information about Bean Validation    454

Chapter 22: Bean Validation: Advanced Topics            455

22.1    Creating Custom Constraints    455

22.2    Customizing Validator Messages   457

22.3    Grouping Constraints    457

22.4    Using Method Constraints in Type Hierarchies    458

Part V: Contexts and Dependency Injection for Java EE             461

Chapter 23: Introduction to Contexts and Dependency Injection for Java EE             463

23.1 Getting Started    464

23.2 Overview of CDI    466

23.3 About Beans    467

23.4 About CDI Managed Beans    468

23.5 Beans as Injectable Objects    468

23.6 Using Qualifiers    469

23.7 Injecting Beans    470

23.8 Using Scopes    471

23.9 Giving Beans EL Names    473

23.10 Adding Setter and Getter Methods    473

23.11 Using a Managed Bean in a Facelets Page   474

23.12 Injecting Objects by Using Producer Methods    474

23.13 Configuring a CDI Application   475

23.14 Using the @PostConstruct and @PreDestroy Annotations with CDI Managed Bean Classes    476

23.15 Further Information about CDI   477

Chapter 24: Running the Basic Contexts and Dependency Injection Examples           479

24.1 The simplegreeting CDI Example    479

24.2 The guessnumber-cdi CDI Example    483

Chapter 25: Contexts and Dependency Injection for Java EE: Advanced Topics           493

25.1 Packaging CDI Applications   493

25.2 Using Alternatives in CDI Applications   494

25.3 Using Producer Methods, Producer Fields, and Disposer Methods in CDI Applications   497

25.4 Using Predefined Beans in CDI Applications    499

25.5 Using Events in CDI Applications    501

25.6 Using Interceptors in CDI Applications    504

25.7 Using Decorators in CDI Applications    506

25.8 Using Stereotypes in CDI Applications    507

Chapter 26: Running the Advanced Contexts and Dependency Injection Examples        511

26.1 The encoder Example: Using Alternatives    511

26.2 The producermethods Example: Using a Producer Method to Choose a Bean Implementation    517

26.3 The producerfields Example: Using Producer Fields to Generate Resources    520

26.4 The billpayment Example: Using Events and Interceptors     527

26.5 The decorators Example: Decorating a Bean    535

Part VI: Web Services           539

Chapter 27: Introduction to Web Services            541

27.1 What Are Web Services?     541

27.2 Types of Web Services     541

27.3 Deciding Which Type of Web Service to Use    544

Chapter 28: Building Web Services with JAX-WS                 545

28.1 Creating a Simple Web Service and Clients with JAX-WS    546

28.2 Types Supported by JAX-WS    555

28.3 Web Services Interoperability and JAX-WS    557

28.4 Further Information about JAX-WS    558

Chapter 29: Building RESTful Web Services with JAX-RS            559

29.1 What Are RESTful Web Services?    559

29.2 Creating a RESTful Root Resource Class    561

29.3 Example Applications for JAX-RS    578

29.4 Further Information about JAX-RS    583

Chapter 30: Accessing REST Resources with the JAX-RS Client API            585

30.1 Overview of the Client API    585

30.2 Using the Client API in the JAX-RS Example Applications   589

30.3 Advanced Features of the Client API    592

Chapter 31: JAX-RS: Advanced Topics and an Example                 597

31.1 Annotations for Field and Bean Properties of Resource Classes    598

31.2 Validating Resource Data with Bean Validation    601

31.3 Subresources and Runtime Resource Resolution    604

31.4 Integrating JAX-RS with EJB Technology and CDI    606

31.5 Conditional HTTP Requests    608

31.6 Runtime Content Negotiation    609

31.7 Using JAX-RS with JAXB   611

31.8 The customer Example Application    618

Index                                         627


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020