You are previewing Java EE 7 Recipes: A Problem-Solution Approach.
O'Reilly logo
Java EE 7 Recipes: A Problem-Solution Approach

Book Description

Java EE 7 Recipes takes an example-based approach in showing how to program Enterprise Java applications in many different scenarios. Be it a small-business web application, or an enterprise database application, Java EE 7 Recipes provides effective and proven solutions to accomplish just about any task that you may encounter. You can feel confident using the reliable solutions that are demonstrated in this book in your personal or corporate environment.

The solutions in Java EE 7 Recipes are built using the most current Java Enterprise specifications, including EJB 3.2, JSF 2.2, Expression Language 3.0, Servlet 3.1, and JMS 2.0. While older technologies and frameworks exist, it is important to be forward-looking and take advantage of all that the latest technologies offer. Rejuvenate your Java expertise to use the freshest capabilities, or perhaps learn Java Enterprise development for the first time and discover one of the most widely used and most powerful platforms available for application development today. Let Java EE 7 Recipes show you the way by showing how to build streamlined and reliable applications much faster and easier than ever before by making effective use of the latest frameworks and features on offer in the Java EE 7 release.

  • Shows off the most current Java Enterprise Edition technologies.

  • Provides solutions to creating sophisticated user interfaces.

  • Demonstrates proven solutions for effective database access.

Table of Contents

  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewers
  7. Acknowledgments
  8. Introduction
  9. CHAPTER 1: Introduction to Servlets
    1. 1-1. Setting Up a Java Enterprise Environment
    2. 1-2. Developing a Servlet
    3. 1-3. Packaging, Compiling, and Deploying a Servlet
    4. 1-4. Registering Servlets Without WEB-XML
    5. 1-5. Displaying Dynamic Content with a Servlet
    6. 1-6. Handling Requests and Responses
    7. 1-7. Listening for Servlet Container Events
    8. 1-8. Setting Initialization Parameters
    9. 1-9. Filtering Web Requests
    10. 1-10. Listening for Attribute Changes
    11. 1-11. Applying a Listener to a Session
    12. 1-12. Managing Session Attributes
    13. 1-13. Downloading a File
    14. 1-14. Dispatching Requests
    15. 1-15. Redirecting to a Different Site
    16. 1-16. Securely Maintaining State Within the Browser
    17. 1-17. Finalizing Servlet Tasks
    18. 1-18. Reading and Writing with Nonblocking I/O
  10. CHAPTER 2: JavaServer Pages
    1. 2-1. Creating a Simple JSP Page
    2. 2-2. Embedding Java into a JSP Page
    3. 2-3. Separating Business Logic from View Code
    4. 2-4. Yielding or Setting Values
    5. 2-5. Invoking a Function in a Conditional Expression
    6. 2-6. Creating a JSP Document
    7. 2-7. Embedding Expressions in EL
    8. 2-8. Accessing Parameters in Multiple Pages
    9. 2-9. Creating a Custom JSP Tag
    10. 2-10. Including Other JSPs into a Page
    11. 2-11. Creating an Input Form for a Database Record
    12. 2-12. Looping Through Database Records Within a Page
    13. 2-13. Handling JSP Errors
    14. 2-14. Disabling Scriptlets in Pages
    15. 2-15. Ignoring EL in Pages
  11. CHAPTER 3: The Basics of JavaServer Faces
    1. 3-1. Writing a Simple JSF Application
    2. 3-2. Writing a Managed Bean
    3. 3-3. Building Sophisticated JSF Views with Components
    4. 3-4. Displaying Messages in JSF Pages
    5. 3-5. Navigation Based Upon Conditions
    6. 3-6. Updating Messages Without Recompiling
    7. 3-7. Validating User Input
    8. 3-8. Evaluation of Page Expressions Immediately
    9. 3-9. Passing Page Parameters to Methods
    10. 3-10. Arithmetic and Reserved Words in Expressions
    11. 3-11. Creating Bookmarkable URLs
    12. 3-12. Displaying Lists of Objects
    13. 3-13. Invoking Managed Bean Actions on Life-Cycle Phase Events
  12. CHAPTER 4: Facelets
    1. 4-1. Creating a Page Template
    2. 4-2. Applying a Template to Your Views
    3. 4-3. Ensuring Resource Availability from All Views
    4. 4-4. Creating Reusable Templates That Act As Components
    5. 4-5. Handling Variable-Length Data on a Page
    6. 4-6. Debugging View Content
    7. 4-7. Writing a Custom Resolver for Locating Facelets Templates and Resources
  13. CHAPTER 5: JavaServer Faces Standard Components
    1. Component and Tag Primer
    2. 5-1. Creating an Input Form
    3. 5-2. Invoking Actions from Within a Page
    4. 5-3. Displaying Output
    5. 5-4. Adding Form Validation
    6. 5-5. Adding Select Lists to Pages
    7. 5-6. Adding Graphics to Your Pages
    8. 5-7. Adding Check Boxes to a View
    9. 5-8. Adding Radio Buttons to a View
    10. 5-9. Structuring View Layout
    11. 5-10. Displaying a Collection of Data
    12. 5-11. Utilizing Custom JSF Component Libraries
    13. 5-12. Implementing File Uploading
  14. CHAPTER 6: Advanced JavaServer Faces and Ajax
    1. 6-1. Validating Input with Ajax
    2. 6-2. Submitting Pages Without Page Reloads
    3. 6-3. Making Partial-Page Updates
    4. 6-4. Applying Ajax Functionality to a Group of Components
    5. 6-5. Custom Processing of Ajax Functionality
    6. 6-6. Custom Conversion of Input Values
    7. 6-7. Maintaining Managed Bean Scopes for a Session
    8. 6-8. Listening for System-Level Events
    9. 6-9. Listening for Component Events
    10. 6-10. Invoking a Managed Bean Action on Render
    11. 6-11. Asynchronously Updating Components
    12. 6-12. Developing JSF Components Containing HTML5
    13. 6-13. Listening to JSF Phases
    14. 6-14. Adding Autocompletion to Text Fields
    15. 6-15. Developing Custom Constraint Annotations
    16. 6-16. Customizing Data Tables
    17. 6-17. Developing a Page Flow
    18. 6-18. Constructing a JSF View in Pure HTML5
  15. CHAPTER 7: JDBC
    1. 7-1. Obtaining Database Drivers and Adding Them to the CLASSPATH
    2. 7-2. Connecting to a Database
    3. 7-3. Handling Database Connection Exceptions
    4. 7-4. Simplifying Connection Management
    5. 7-5. Querying a Database
    6. 7-6. Performing CRUD Operations
    7. 7-7. Preventing SQL Injection
    8. 7-8. Utilizing Java Objects for Database Access
    9. 7-9. Displaying Database Results in JSF Views
    10. 7-10. Navigating Data with Scrollable ResultSets
    11. 7-11. Calling PL/SQL Stored Procedures
    12. 7-12. Querying and Storing Large Objects
    13. 7-13. Caching Data for Use When Disconnected
    14. 7-14. Joining RowSet Objects When Not Connected to the Data Source
  16. CHAPTER 8: Object-Relational Mapping
    1. 8-1. Creating an Entity
    2. 8-2. Mapping Data Types
    3. 8-3. Creating a Persistence Unit
    4. 8-4. Using Database Sequences to Create Primary Key Values
    5. 8-5. Generating Primary Keys with More Than One Attribute
    6. 8-6. Defining a One-to-One Relationship
    7. 8-7. Defining One-to-Many and Many-to-One Relationships
    8. 8-8. Defining a Many-to-Many Relationship
    9. 8-9. Querying with Named Queries
    10. 8-10. Performing Validation on Entity Fields
    11. 8-11. Generating Database Schema Objects Automatically
  17. CHAPTER 9: Enterprise JavaBeans
    1. 9-1. Obtaining an Entity Manager
    2. 9-2. Developing a Stateless Session Bean
    3. 9-3. Developing a Stateful Session Bean
    4. 9-4. Utilizing Session Beans with JSF
    5. 9-5. Persisting an Object
    6. 9-6. Updating an Object
    7. 9-7. Returning a Table Model
    8. 9-8. Creating a Singleton Bean
    9. 9-9. Scheduling a Timer Service
    10. 9-10. Performing Optional Transaction Life-Cycle Callbacks
    11. 9-11. Ensuring a Stateful Session Bean Is Not Passivated
    12. 9-12. Denoting Local and Remote Interfaces
    13. 9-13. Processing Messages Asynchronously from Enterprise Beans
  18. CHAPTER 10: The Query API and JPQL
    1. 10-1. Querying All Instances of an Entity
    2. 10-2. Setting Parameters to Filter Query Results
    3. 10-3. Returning a Single Object
    4. 10-4. Creating Native Queries
    5. 10-5. Querying More Than One Entity
    6. 10-6. Calling JPQL Aggregate Functions
    7. 10-7. Invoking Database Stored Procedures Natively
    8. 10-8. Joining to Retrieve Instances Matching All Cases
    9. 10-9. Joining to Retrieve All Rows Regardless of Match
    10. 10-10. Applying JPQL Functional Expressions
    11. 10-11. Forcing Query Execution Rather Than Cache Use
    12. 10-12. Performing Bulk Updates and Deletes
    13. 10-13. Retrieving Entity Subclasses
    14. 10-14. Joining with ON Conditions
  19. CHAPTER 11: Oracle's GlassFish
    1. 11-1. Installing the GlassFish Application Server
    2. 11-2. Logging into the Administrative Console
    3. 11-3. Changing the Administrator User Password
    4. 11-4. Deploying a WAR File
    5. 11-5. Adding a Database Resource
    6. 11-6. Adding Forms-Based Authentication
    7. 11-7. Configuring and Using JavaMail
  20. CHAPTER 12: Contexts and Dependency Injection
    1. 12-1. Injecting a Bean or Other Object
    2. 12-2. Binding a Bean to JSF Views
    3. 12-3. Allocating a Specific Bean for Injection
    4. 12-4. Determining Scope of a Bean
    5. 12-5. Injecting Non-bean Objects
    6. 12-6. Ignoring Classes
    7. 12-7. Disposing of Producer Fields
    8. 12-8. Specifying an Alternative Implementation at Deployment Time
    9. 12-9. Injecting Bean Metadata
  21. CHAPTER 13: Java Message Service
    1. 13-1. Creating JMS Resources
    2. 13-2. Creating a Session
    3. 13-3. Creating and Sending a Message
    4. 13-4. Receiving Messages
    5. 13-5. Filtering Messages
    6. 13-6. Inspecting Message Queues
    7. 13-7. Creating Durable Message Subscribers
    8. 13-8. Delaying Message Delivery
  22. CHAPTER 14: Authentication and Security
    1. 14-1. Setting Up Application Users and Groups in GlassFish
    2. 14-2. Performing Basic Web Application Authentication
    3. 14-3. Developing a Programmatic Login Form
    4. 14-4. Managing Page Access Within a JSF Application
    5. 14-5. Configuring LDAP Authentication Within GlassFish
    6. 14-6. Configuring Custom Security Certificates Within GlassFish
  23. CHAPTER 15: Java Web Services
    1. 15-1. Creating a JAX-WS Web Service Endpoint
    2. 15-2. Deploying a JAX-WS Web Service
    3. 15-3. Consuming a JAX-WS Web Service via WSDL
    4. 15-4. Consuming a JAX-WS Web Service via a Stand-Alone Application Client
    5. 15-5. Integrating Web Services into a Java EE Project
    6. 15-6. Developing a RESTful Web Service
    7. 15-7. Consuming and Producing with REST
    8. 15-8. Writing a JAX-RS Client
    9. 15-9. Filtering Requests and Responses
    10. 15-10. Processing Long-Running Operations Asynchronously
  24. CHAPTER 16: Enterprise Solutions Using Alternative Programming Languages
    1. 16-1. Developing Servlets with Groovy
    2. 16-2. Working with Groovy Servlet Parameters
    3. 16-3. Developing Servlets with Jython
  25. CHAPTER 17: WebSockets and JSON-P
    1. 17-1. Creating a WebSocket Endpoint
    2. 17-2. Sending Messages to a WebSocket Endpoint
    3. 17-3. Building a JSON Object
    4. 17-4. Writing a JSON Object to Disk
    5. 17-5. Reading JSON from an Input Source
  26. CHAPTER 18: JavaFX in the Enterprise
    1. 18-1. Developing a Basic JavaFX Application
    2. 18-2. Incorporating Databases into a JavaFX Application
    3. 18-3. Constructing a Sophisticated UI Containing EJB Data
    4. 18-4. Developing an Enterprise Application Using MVC
    5. 18-5. Incorporating REST Services into JavaFX Applications
  27. CHAPTER 19: Concurrency and Batch Applications
    1. 19-1. Creating Resources for Processing Tasks Asynchronously in an Application Server
    2. 19-2. Configuring and Creating a Reporter Task
    3. 19-3. Running More Than One Task Concurrently
    4. 19-4. Utilizing Transactions Within a Task
    5. 19-5. Running Concurrent Tasks at Scheduled Times
    6. 19-6. Creating Thread Instances
    7. 19-7. Creating an Item-Oriented Batch Process
  28. APPENDIX A: Java EE Development with NetBeans IDE
    1. A-1. Configuring Application Servers Within NetBeans
    2. A-2. Creating a NetBeans Java Web Project
    3. A-3. Creating JSF Application Files
    4. A-4. Developing EJB Entity Classes
    5. A-5. JPQL
    6. A-6. HTML5
  29. Index