You are previewing The Java EE 7 Tutorial: Volume 1, Fifth Edition.
O'Reilly logo
The Java EE 7 Tutorial: Volume 1, Fifth Edition

Book Description

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).

Table of Contents

  1. About This eBook
  2. Title Page
  3. Copyright Page
  4. Contents
  5. Preface
    1. Audience
    2. Before You Read This Book
    3. Related Documentation
    4. The Oracle Accessibility Program
    5. Conventions
    6. Default Paths and File Names
    7. Acknowledgments
  6. Part I: Introduction
    1. 1. Overview
      1. 1.1 Java EE 7 Platform Highlights
      2. 1.2 Java EE Application Model
      3. 1.3 Distributed Multitiered Applications
      4. 1.4 Java EE Containers
      5. 1.5 Web Services Support
      6. 1.6 Java EE Application Assembly and Deployment
      7. 1.7 Development Roles
      8. 1.8 Java EE 7 APIs
      9. 1.9 Java EE 7 APIs in the Java Platform, Standard Edition 7
      10. 1.10 GlassFish Server Tools
    2. 2. Using the Tutorial Examples
      1. 2.1 Required Software
      2. 2.2 Starting and Stopping GlassFish Server
      3. 2.3 Starting the Administration Console
      4. 2.4 Starting and Stopping the Java DB Server
      5. 2.5 Building the Examples
      6. 2.6 Tutorial Example Directory Structure
      7. 2.7 Java EE 7 Maven Archetypes in the Tutorial
      8. 2.8 Getting the Latest Updates to the Tutorial
      9. 2.9 Debugging Java EE Applications
  7. Part II: Platform Basics
    1. 3. Resource Creation
      1. 3.1 Resources and JNDI Naming
      2. 3.2 DataSource Objects and Connection Pools
      3. 3.3 Creating Resources Administratively
    2. 4. Injection
      1. 4.1 Resource Injection
      2. 4.2 Dependency Injection
      3. 4.3 The Main Differences between Resource Injection and Dependency Injection
    3. 5. Packaging
      1. 5.1 Packaging Applications
      2. 5.2 Packaging Enterprise Beans
      3. 5.3 Packaging Web Archives
      4. 5.4 Packaging Resource Adapter Archives
  8. Part III: The Web Tier
    1. 6. Getting Started with Web Applications
      1. 6.1 Web Applications
      2. 6.2 Web Application Lifecycle
      3. 6.3 A Web Module That Uses JavaServer Faces Technology: The hello1 Example
      4. 6.4 A Web Module That Uses Java Servlet Technology: The hello2 Example
      5. 6.5 Configuring Web Applications
      6. 6.6 Further Information about Web Applications
    2. 7. JavaServer Faces Technology
      1. 7.1 What Is a JavaServer Faces Application?
      2. 7.2 JavaServer Faces Technology Benefits
      3. 7.3 A Simple JavaServer Faces Application
      4. 7.4 User Interface Component Model
      5. 7.5 Navigation Model
      6. 7.6 The Lifecycle of a JavaServer Faces Application
      7. 7.7 Partial Processing and Partial Rendering
      8. 7.8 Further Information about JavaServer Faces Technology
    3. 8. Introduction to Facelets
      1. 8.1 What Is Facelets?
      2. 8.2 The Lifecycle of a Facelets Application
      3. 8.3 Developing a Simple Facelets Application: The guessnumber-jsf Example Application
      4. 8.4 Using Facelets Templates
      5. 8.5 Composite Components
      6. 8.6 Web Resources
      7. 8.7 Relocatable Resources
      8. 8.8 Resource Library Contracts
      9. 8.9 HTML5-Friendly Markup
    4. 9. Expression Language
      1. 9.1 Overview of the EL
      2. 9.2 Immediate and Deferred Evaluation Syntax
      3. 9.3 Value and Method Expressions
      4. 9.4 Operations on Collection Objects
      5. 9.5 Operators
      6. 9.6 Reserved Words
      7. 9.7 Examples of EL Expressions
      8. 9.8 Further Information about the Expression Language
    5. 10. Using JavaServer Faces Technology in Web Pages
      1. 10.1 Setting Up a Page
      2. 10.2 Adding Components to a Page Using HTML Tag Library Tags
      3. 10.3 Using Core Tags
    6. 11. Using Converters, Listeners, and Validators
      1. 11.1 Using the Standard Converters
      2. 11.2 Registering Listeners on Components
      3. 11.3 Using the Standard Validators
      4. 11.4 Referencing a Managed Bean Method
    7. 12. Developing with JavaServer Faces Technology
      1. 12.1 Managed Beans in JavaServer Faces Technology
      2. 12.2 Writing Bean Properties
      3. 12.3 Writing Managed Bean Methods
    8. 13. Using Ajax with JavaServer Faces Technology
      1. 13.1 Overview of Ajax
      2. 13.2 Using Ajax Functionality with JavaServer Faces Technology
      3. 13.3 Using Ajax with Facelets
      4. 13.4 Sending an Ajax Request
      5. 13.5 Monitoring Events on the Client
      6. 13.6 Handling Errors
      7. 13.7 Receiving an Ajax Response
      8. 13.8 Ajax Request Lifecycle
      9. 13.9 Grouping of Components
      10. 13.10 Loading JavaScript as a Resource
      11. 13.11 The ajaxguessnumber Example Application
      12. 13.12 Further Information about Ajax in JavaServer Faces Technology
    9. 14. Composite Components: Advanced Topics and an Example
      1. 14.1 Attributes of a Composite Component
      2. 14.2 Invoking a Managed Bean
      3. 14.3 Validating Composite Component Values
      4. 14.4 The compositecomponentexample Example Application
    10. 15. Creating Custom UI Components and Other Custom Objects
      1. 15.1 Determining Whether You Need a Custom Component or Renderer
      2. 15.2 Understanding the Image Map Example
      3. 15.3 Steps for Creating a Custom Component
      4. 15.4 Creating Custom Component Classes
      5. 15.5 Delegating Rendering to a Renderer
      6. 15.6 Implementing an Event Listener
      7. 15.7 Handling Events for Custom Components
      8. 15.8 Defining the Custom Component Tag in a Tag Library Descriptor
      9. 15.9 Using a Custom Component
      10. 15.10 Creating and Using a Custom Converter
      11. 15.11 Creating and Using a Custom Validator
      12. 15.12 Binding Component Values and Instances to Managed Bean Properties
      13. 15.13 Binding Converters, Listeners, and Validators to Managed Bean Properties
    11. 16. Configuring JavaServer Faces Applications
      1. 16.1 Using Annotations to Configure Managed Beans
      2. 16.2 Application Configuration Resource File
      3. 16.3 Using Faces Flows
      4. 16.4 Configuring Managed Beans
      5. 16.5 Registering Application Messages
      6. 16.6 Using Default Validators
      7. 16.7 Registering a Custom Validator
      8. 16.8 Registering a Custom Converter
      9. 16.9 Configuring Navigation Rules
      10. 16.10 Registering a Custom Renderer with a Render Kit
      11. 16.11 Registering a Custom Component
      12. 16.12 Basic Requirements of a JavaServer Faces Application
    12. 17. Java Servlet Technology
      1. 17.1 What Is a Servlet?
      2. 17.2 Servlet Lifecycle
      3. 17.3 Sharing Information
      4. 17.4 Creating and Initializing a Servlet
      5. 17.5 Writing Service Methods
      6. 17.6 Filtering Requests and Responses
      7. 17.7 Invoking Other Web Resources
      8. 17.8 Accessing the Web Context
      9. 17.9 Maintaining Client State
      10. 17.10 Finalizing a Servlet
      11. 17.11 Uploading Files with Java Servlet Technology
      12. 17.12 Asynchronous Processing
      13. 17.13 Nonblocking I/O
      14. 17.14 Protocol Upgrade Processing
      15. 17.15 The mood Example Application
      16. 17.16 The fileupload Example Application
      17. 17.17 The dukeetf Example Application
      18. 17.18 Further Information about Java Servlet Technology
    13. 18. Java API for WebSocket
      1. 18.1 Introduction to WebSocket
      2. 18.2 Creating WebSocket Applications in the Java EE Platform
      3. 18.3 Programmatic Endpoints
      4. 18.4 Annotated Endpoints
      5. 18.5 Sending and Receiving Messages
      6. 18.6 Maintaining Client State
      7. 18.7 Using Encoders and Decoders
      8. 18.8 Path Parameters
      9. 18.9 Handling Errors
      10. 18.10 Specifying an Endpoint Configurator Class
      11. 18.11 The dukeetf2 Example Application
      12. 18.12 The websocketbot Example Application
      13. 18.13 Further Information about WebSocket
    14. 19. JSON Processing
      1. 19.1 Introduction to JSON
      2. 19.2 JSON Processing in the Java EE Platform
      3. 19.3 Using the Object Model API
      4. 19.4 Using the Streaming API
      5. 19.5 JSON in Java EE RESTful Web Services
      6. 19.6 The jsonpmodel Example Application
      7. 19.7 The jsonpstreaming Example Application
      8. 19.8 Further Information about the Java API for JSON Processing
    15. 20. Internationalizing and Localizing Web Applications
      1. 20.1 Java Platform Localization Classes
      2. 20.2 Providing Localized Messages and Labels
      3. 20.3 Date and Number Formatting
      4. 20.4 Character Sets and Encodings
  9. Part IV: Bean Validation
    1. 21. Introduction to Bean Validation
      1. 21.1 Using Bean Validation Constraints
      2. 21.2 Validating Null and Empty Strings
      3. 21.3 Validating Constructors and Methods
      4. 21.4 Further Information about Bean Validation
    2. 22. Bean Validation: Advanced Topics
      1. 22.1 Creating Custom Constraints
      2. 22.2 Customizing Validator Messages
      3. 22.3 Grouping Constraints
      4. 22.4 Using Method Constraints in Type Hierarchies
  10. Part V: Contexts and Dependency Injection for Java EE
    1. 23. Introduction to Contexts and Dependency Injection for Java EE
      1. 23.1 Getting Started
      2. 23.2 Overview of CDI
      3. 23.3 About Beans
      4. 23.4 About CDI Managed Beans
      5. 23.5 Beans as Injectable Objects
      6. 23.6 Using Qualifiers
      7. 23.7 Injecting Beans
      8. 23.8 Using Scopes
      9. 23.9 Giving Beans EL Names
      10. 23.10 Adding Setter and Getter Methods
      11. 23.11 Using a Managed Bean in a Facelets Page
      12. 23.12 Injecting Objects by Using Producer Methods
      13. 23.13 Configuring a CDI Application
      14. 23.14 Using the @PostConstruct and @PreDestroy Annotations with CDI Managed Bean Classes
      15. 23.15 Further Information about CDI
    2. 24. Running the Basic Contexts and Dependency Injection Examples
      1. 24.1 The simplegreeting CDI Example
      2. 24.2 The guessnumber-cdi CDI Example
    3. 25. Contexts and Dependency Injection for Java EE: Advanced Topics
      1. 25.1 Packaging CDI Applications
      2. 25.2 Using Alternatives in CDI Applications
      3. 25.3 Using Producer Methods, Producer Fields, and Disposer Methods in CDI Applications
      4. 25.4 Using Predefined Beans in CDI Applications
      5. 25.5 Using Events in CDI Applications
      6. 25.6 Using Interceptors in CDI Applications
      7. 25.7 Using Decorators in CDI Applications
      8. 25.8 Using Stereotypes in CDI Applications
    4. 26. Running the Advanced Contexts and Dependency Injection Examples
      1. 26.1 The encoder Example: Using Alternatives
      2. 26.2 The producermethods Example: Using a Producer Method to Choose a Bean Implementation
      3. 26.3 The producerfields Example: Using Producer Fields to Generate Resources
      4. 26.4 The billpayment Example: Using Events and Interceptors
      5. 26.5 The decorators Example: Decorating a Bean
  11. Part VI: Web Services
    1. 27. Introduction to Web Services
      1. 27.1 What Are Web Services?
      2. 27.2 Types of Web Services
      3. 27.3 Deciding Which Type of Web Service to Use
    2. 28. Building Web Services with JAX-WS
      1. 28.1 Creating a Simple Web Service and Clients with JAX-WS
      2. 28.2 Types Supported by JAX-WS
      3. 28.3 Web Services Interoperability and JAX-WS
      4. 28.4 Further Information about JAX-WS
    3. 29. Building RESTful Web Services with JAX-RS
      1. 29.1 What Are RESTful Web Services?
      2. 29.2 Creating a RESTful Root Resource Class
      3. 29.3 Example Applications for JAX-RS
      4. 29.4 Further Information about JAX-RS
    4. 30. Accessing REST Resources with the JAX-RS Client API
      1. 30.1 Overview of the Client API
      2. 30.2 Using the Client API in the JAX-RS Example Applications
      3. 30.3 Advanced Features of the Client API
    5. 31. JAX-RS: Advanced Topics and an Example
      1. 31.1 Annotations for Field and Bean Properties of Resource Classes
      2. 31.2 Validating Resource Data with Bean Validation
      3. 31.3 Subresources and Runtime Resource Resolution
      4. 31.4 Integrating JAX-RS with EJB Technology and CDI
      5. 31.5 Conditional HTTP Requests
      6. 31.6 Runtime Content Negotiation
      7. 31.7 Using JAX-RS with JAXB
      8. 31.8 The customer Example Application
  12. Index