<p><span>Take a problem-solution approach for programming enterprise Java or Java EE applications and microservices for cloud-based solutions, enterprise database applications, and even small business web applications. </span><span>Java EE to Jakarta EE 10 Recipes</span><span> provides effective, pr
Java EE to Jakarta EE 10 Recipes: A Problem-Solution Approach for Enterprise Java
✍ Scribed by Josh Juneau, Tarun Telang
- Publisher
- Apress
- Year
- 2022
- Tongue
- English
- Leaves
- 719
- Category
- Library
No coin nor oath required. For personal study only.
✦ Synopsis
Take a problem-solution approach for programming enterprise Java or Java EE applications and microservices for cloud-based solutions, enterprise database applications, and even small business web applications. Java EE to Jakarta EE 10 Recipes provides effective, practical, and proven code snippets that you can immediately use 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.
Java EE was made open source under the Eclipse Foundation, and Jakarta EE is the new name for what used to be termed the Java Platform, Enterprise Edition. This book helps you rejuvenate your Java expertise and put the platform’s latest capabilities to use for quickly developing robust applications. If you are new to Jakarta EE, this book will help you learn the features of the platform and benefit from one of the most widely usedand powerful technologies available for cloud-native enterprise application development today.
Examples in this book highlight Jakarta EE’s capabilities, helping you to build streamlined and reliable applications using the latest in Java technologies. The book takes a problem-solution approach in which each section introduces a common programming problem, showing you how to solve that problem in the best possible way using the latest features in Jakarta EE. Solutions in the form of working code examples are presented that you can download and use immediately in your own projects. Clear descriptions are provided to help you understand and learn to build further on the solutions provided.
This is the ideal book for the code-focused programmer interested in keeping up with the future of enterprise development on the Java Platform.
What You Will Learn
- Develop enterprise java applications using the latest open-source Jakarta EE platform
- Create great-looking user interfaces using Jakarta Servlets, Jakarta Server Pages, Jakarta Server Faces and the Eclipse Krazo framework (an implementation of Jakarta MVC)
- Build database applications using Jakarta NoSQL, Jakarta Persistence, and Jakarta Enterprise Beans.
- Develop enterprise grade applications using Context & Dependency Injection, and Jakarta RESTFul web services
- Automate testing through cohesive test suites built on Arquillian for Jakarta EE applications
- Build loosely coupled distributed applications using Jakarta Messaging
- Deploy microservices applications in cloud environments using Docker
- Secure applications utilizing the Jakarta EE Security API
Who This Book Is For
Java developers interested in quickly finding effective and proven solutions without reading through a lengthymanual and scrubbing for techniques.
✦ Table of Contents
Table of Contents
About the Authors
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: Jakarta Servlets
1-1. Setting Up a Jakarta EE Application Server
Problem
Solution
How It Works
1-2. Developing a Servlet
Problem
Solution
How It Works
1-3. Packaging, Compiling, and Deploying a Servlet
Problem
Solution
Quick Start
How It Works
1-4. Registering a Servlet Without web.xml
Problem
Solution
How It Works
1-5. Displaying Dynamic Content with a Servlet
Problem
Solution
How It Works
1-6. Handling Requests and Responses
Problem
Solution
How It Works
1-7. Listening for Servlet Container Events
Problem
Solution
How It Works
1-8. Setting Initialization Parameters
Problem
Solution #1
Solution #2
How It Works
1-9. Filtering Web Requests
Problem
Solution
How It Works
1-10. Listening for Attribute Changes
Problem
Solution
How It Works
1-11. Applying a Listener to a Session
Problem
Solution
How It Works
1-12. Managing Session Attributes
Problem
Solution
How It Works
1-13. Downloading a File
Problem
Solution
How It Works
1-14. Dispatching Requests
Problem
Solution
How It Works
1-15. Redirecting to a Different Site
Problem
Solution
How It Works
1-16. Securely Maintaining State Within the Browser
Problem
Solution
How It Works
1-17. Finalizing Servlet Tasks
Problem
Solution
How It Works
1-18. Reading and Writing with Nonblocking I/O
Problem
Solution
How It Works
1-19. Pushing Resources from a Server to a Client
Problem
Solution
How It Works
Chapter 2: Jakarta Server Pages
2-1. Creating a Simple Jakarta Server Page
Problem
Solution
How It Works
2-2. Embedding Java into a Jakarta Server Page
Problem
Solution
How It Works
2-3. Separating Business Logic from View Code
Problem
Solution
How It Works
2-4. Yielding or Setting Values
Problem
Solution
How It Works
2-5. Invoking a Function in a Conditional Expression
Problem
Solution
How It Works
2-6. Creating a Jakarta Server Page Document
Problem
Solution
How It Works
2-7. Embedding Expressions in Jakarta Expression Language
Problem
Solution
How It Works
2-8. Accessing Parameters in Multiple Pages
Problem
Solution
How It Works
2-9. Creating a Custom Jakarta Server Tag
Problem
Solution
How It Works
2-10. Including Other Jakarta Server Pages into a Page
Problem
Solution
How It Works
2-11. Creating an Input Form for a Database Record
Problem
Solution
How It Works
2-12. Looping Through Database Records Within a Page
Problem
Solution
How It Works
2-13. Handling Errors in Jakarta Server Pages
Problem
Solution
How It Works
2-14. Disabling Scriptlets in Pages
Problem
Solution
How It Works
2-15. Ignoring Jakarta Expression Language in Pages
Problem
Solution #1
Solution #2
Solution #3
How It Works
Chapter 3: Jakarta Server Faces
3-1. Writing a Simple Jakarta Server Faces Application
Problem
Solution #1
Project Dependencies
Displaying a Jakarta Server Faces Controller Field Value
Examining the Jakarta Server Faces Controller
Breaking Down a Jakarta Server Faces Application
3-2. Writing a Controller Class
Problem
Solution
Controller Class
Jakarta Server Faces View
How It Works
Scopes
3-3. Building Sophisticated Jakarta Server Faces Views with Components
Problem
Solution
How It Works
3-4. Displaying Messages in Jakarta Server Faces Pages
Problem
Solution
How It Works
3-5. Updating Messages Without Recompiling
Problem
Solution
How It Works
3-6. Navigating Based upon Conditions
Problem
Solution
How It Works
3-7. Validating User Input
Problem
Solution
How It Works
3-8. Evaluating Page Expressions Immediately
Problem
Solution
How It Works
3-9. Passing Page Parameters to Methods
Problem
Solution
How It Works
3-10. Using Operators and Reserved Words in Expressions
Problem
Solution
How It Works
3-11. Creating Bookmarkable URLs
Problem
Solution
How It Works
3-12. Displaying Lists of Objects
Problem
Solution
How It Works
3-13. Creating Page Templates
Problem
Solution
How It Works
3-14. Applying Templates
Problem
Solution
View #1: recipe03_14a.xhtml
View #2: recipe03_14b.xhtml
View #3: recipe03_14c.xhtml
Managed Bean Controller: AuthorController
How It Works
Applying Templates
3-15. Adding Resources into the Mix
Problem
Solution
How It Works
Chapter 4: Advanced Jakarta Server Faces
4-1. Component and Tag Primer
Common Component Tag Attributes
Common JavaScript Component Tags
Binding Components to Properties
Project Folder Structure for This Chapter
4-2. Creating an Input Form
Problem
Solution
The View: recipe04_01.xhtml
Managed Bean: Contact.java
Managed Bean Controller: ContactController.java
How It Works
4-3. Invoking Actions from Within a Page
Problem
Solution
The View: manageAccount.xhtml
The View: recipe04_02.xhtml
Managed Bean: Subscription.java
Managed Bean Controller: ContactController.java
How It Works
4-4. Displaying Output
Problem
Solution
The View: recipe04_03.xhtml
Managed Bean: ContactController.java
How It Works
The View: home.xhtml
4-5. Adding Form Validation
Problem
Solution #1
Solution #2
Solution #3
How It Works
4-6. Adding Select Lists to Pages
Problem
Solution
The View: recipe04_05.xhtml
Managed Bean Controller: ContactController.java
How It Works
Populating the Select Lists
Regarding Each Component Type
4-7. Adding Graphics to Your Pages
Problem
Solution
How It Works
Managed Bean: Book.java
4-8. Adding Check Boxes to a View
Problem
Solution
The View: recipe04_07.xhtml
Managed Bean Controllers
How It Works
4-9. Adding Radio Buttons to a View
Problem
Solution
The View: recipe04_08.xhtml
Managed Bean
How It Works
4-10. Displaying a Collection of Data
Problem
Solution
The View: recipe04_09.xhtml
CSS
Managed Bean
How It Works
4-11. Implementing File Uploading
Problem
Solution
How It Works
4-12. Validating Input with Ajax
Problem
Solution
4-13. Submitting Pages Without Page Reloads
Problem
Solution
How It Works
4-14. Making Partial-Page Updates
Problem
Solution
How It Works
4-15. Applying Ajax Functionality to a Group of Components
Problem
Solution
How It Works
4-16. Custom Processing of Ajax Functionality
Problem
Solution
How It Works
4-17. Listening for System-Level Events
Problem
Solution
How It Works
4-18. Listening for Component Events
Problem
Solution
How It Works
4-19. Developing a Page Flow
Problem
Solution
How It Works
Defining a Flow
The Flow Controller Class
Navigating Flow View Nodes
Flow Expression Language
4-20. Broadcasting Messages from the Server to All Clients
Problem
Solution
How It Works
4-21. Programmatically Searching for Components
Problem
Solution #1
Solution #2
How It Works
Chapter 5: Jakarta MVC
Project Structure
5-1. Configure an Application for the Jakarta MVC Framework
Problem
Solution
How It Works
5-2. Making Data Available for the Application
Problem
Solution #1
Solution #2
How It Works
5-3. Writing a Controller Class
Problem
Solution
How It Works
5-4. Using a Model to Expose Data to a View
Problem
Solution
How It Works
5-5. Utilizing CDI for Exposing Data
Problem
Solution
How It Works
5-6. Supplying Message Feedback to the User
Problem
Solution
How It Works
5-7. Inserting and Updating Data
Problem
Solution
How It Works
Chapter 6: JDBC with Jakarta EE
6-1. Project Structure
6-2. Obtaining Database Drivers and Adding Them to the CLASSPATH
Problem
Solution
How It Works
6-3. Connecting to a Database
Problem
Solution #1
Solution #2
How It Works
6-4. Handling Database Connection Exceptions
Problem
Solution
How It Works
6-5. Simplifying Connection Management
Problem
Solution
How It Works
6-6. Querying a Database
Problem
Solution
How It Works
6-7. Performing CRUD Operations
Problem
Solution
How It Works
6-8. Preventing SQL Injection
Problem
Solution
How It Works
6-9. Utilizing Java Objects for Database Access
Problem
Solution
How It Works
6-10. Querying and Storing Large Objects
Problem
Solution
How It Works
Chapter 7: Object-Relational Mapping
7-1. Creating an Entity
Problem
Solution
How It Works
7-2. Mapping Data Types
Problem
Solution
How It Works
7-3. Creating a Persistence Unit
Problem
Solution
How It Works
7-4. Using Database Sequences to Create Primary Key Values
Problem
Solution
How It Works
7-5. Generating Primary Keys Using More Than One Attribute
Problem
Solution #1
Solution #2
How It Works
7-6. Defining a One-to-One Relationship
Problem
Solution
How It Works
7-7. Defining One-to-Many and Many-to-One Relationships
Problem
Solution
How It Works
7-8. Defining a Many-to-Many Relationship
Problem
Solution
How It Works
7-9. Querying with Named Queries
Problem
Solution
How It Works
7-10. Performing Validation on Entity Fields
Problem
Solution
How It Works
7-11. Generating Database Schema Objects Automatically
Problem
Solution
How It Works
7-12. Mapping Date-Time Values
Problem
Solution
How It Works
7-13. Using the Same Annotation Many Times
Problem
Solution
How It Works
Chapter 8: Jakarta Enterprise Beans
8-1. Obtaining an Entity Manager
Problem
Solution #1
Solution #2
How It Works
8-2. Developing a Stateless Session Bean
Problem
Solution #1
Solution #2
How It Works
8-3. Developing a Stateful Session Bean
Problem
Solution
How It Works
8-4. Utilizing Session Beans with Jakarta Server Faces
Problem
Solution
How It Works
8-5. Persisting an Object
Problem
Solution
How It Works
8-6. Updating an Object
Problem
Solution
How It Works
8-7. Returning Data to Display in a Table
Problem
Solution #1
Solution #2
How It Works
8-8. Creating a Singleton Bean
Problem
Solution
How It Works
8-9. Scheduling a Timer Service
Problem
Solution #1
Solution #2
How It Works
8-10. Performing Optional Transaction Life-Cycle Callbacks
Problem
Solution
How It Works
8-11. Ensuring a Stateful Session Bean Is Not Passivated
Problem
Solution
How It Works
8-12. Denoting Local and Remote Interfaces
Problem
Solution
How It Works
8-13. Processing Messages Asynchronously from Enterprise Beans
Problem
Solution
How It Works
Chapter 9: Jakarta Persistence Query Language
9-1. Querying All Instances of an Entity
Problem
Solution
How It Works
9-2. Setting Parameters to Filter Query Results
Problem
Solution #1
How It Works
9-3. Returning a Single Object
Problem
Solution
How It Works
9-4. Creating Native Queries
Problem
Solution #1
Solution #2
How It Works
9-5. Querying More Than One Entity
Problem
Solution #1
Solution #2
How It Works
9-6. Calling Jakarta Persistence Query Language Aggregate Functions
Problem
Solution
How It Works
9-7. Invoking Database Stored Procedures Natively
Problem
Solution
How It Works
9-8. Joining to Retrieve Instances from Multiple Entities
Problem
Solution
How It Works
9-9. Joining to Retrieve All Rows Regardless of Match
Problem
Solution
How It Works
9-10. Applying Jakarta Persistence Query Language Functional Expressions
Problem
Solution
How It Works
9-11. Forcing Query Execution Rather Than Cache Use
Problem
Solution
How It Works
9-12. Performing Bulk Updates and Deletes
Problem
Solution
How It Works
9-13. Retrieving Entity Subclasses
Problem
Solution
How It Works
9-14. Joining with ON Conditions
Problem
Solution
How It Works
9-15. Processing Query Results with Streams
Problem
Solution
How It Works
9-16. Converting Attribute Data Types
Problem
Solution
How It Works
Chapter 10: Jakarta Bean Validation
10-1. Validating Fields with Built-In Constraints
Problem
Solution #1
Solution #2
How It Works
10-2. Writing Custom Constraint Validators
Problem
Solution
How It Works
10-3. Validating at the Class Level
Problem
Solution
How It Works
10-4. Validating Parameters
Problem
Solution
How It Works
10-5. Constructor Validation
Problem
Solution
How It Works
10-6. Validating Return Values
Problem
Solution
How It Works
10-7. Defining a Dynamic Validation Error Message
Problem
Solution
How It Works
10-8. Manually Invoking the Validator Engine
Problem
Solution
How It Works
10-9. Grouping Validation Constraints
Problem
Solution
How It Works
Chapter 11: Jakarta Contexts and Dependency Injection
11-1. Injecting a Contextual Bean or Other Objects
Problem
Solution
How It Works
11-2. Binding a Bean to a Web View
Problem
Solution
How It Works
11-3. Allocating a Specific Bean for Injection
Problem
Solution
How It Works
11-4. Determining Scope of a Bean
Problem
Solution
How It Works
11-5. Injecting Non-bean Objects
Problem
Solution
How It Works
11-6. Ignoring Classes
Problem
Solution #1
Solution #2
How It Works
11-7. Disposing of Producer Fields
Problem
Solution
How It Works
11-8. Specifying an Alternative Implementation at Deployment Time
Problem
Solution
How It Works
11-9. Injecting a Bean and Obtaining Metadata
Problem
Solution
How It Works
11-10. Invoking and Processing Events
Problem
Solution
How It Works
11-11. Intercepting Method Invocations
Problem
Solution
How It Works
11-12. Bootstrapping Java SE Environments
Problem
Solution
How It Works
11-13. Enhancing Business Logic of a Method
Problem
Solution
How It Works
Chapter 12: Jakarta Messaging
12-1. Creating Jakarta Messaging Resources
Problem
Solution
How It Works
12-2. Creating a Session
Problem
Solution
Running the Example
How It Works
12-3. Creating and Sending a Message
Problem
Solution #1
Solution #2
Running the Examples
How It Works
12-4. Receiving Messages
Problem
Solution #1
Solution #2
Running the Example
How It Works
12-5. Filtering Messages
Problem
Solution
Running the Example
How It Works
12-6. Inspecting Message Queues
Problem
Solution
Running the Example
How It Works
12-7. Creating Durable Message Subscribers
Problem
Solution
The Topic Connection
Creating the Initial Durable Subscriber
Creating and Publishing a Message
Receiving the Message
Unsubscribing from the Subscription
Running the Example
How It Works
12-8. Delaying Message Delivery
Problem
Solution
How It Works
Chapter 13: RESTful Web Services
13-1. Developing a RESTful Web Service
Problem
Solution #1
Solution #2
How It Works
13-2. Consuming and Producing with REST
Problem
Solution
Producing Output
Producing List Output
Accepting Input
How It Works
13-3. Filtering Requests and Responses
Problem
Solution
How It Works
Filters
Entity Interceptors
Binding Filters and Interceptors
Setting Priorities
13-4. Processing Long-Running Operations Asynchronously
Problem
Solution
How It Works
13-5. Pushing One-Way Asynchronous Updates from Servers
Problem
Solution
How It Works
13-6. Receiving Server-Sent Events As a Client
Problem
Solution
How It Works
Chapter 14: WebSockets and JSON
14-1. Creating a WebSocket Endpoint
Problem
Solution
How It Works
14-2. Sending Messages to a WebSocket Endpoint
Problem
Solution
How It Works
14-3. Building a JSON Object
Problem
Solution
How It Works
14-4. Writing a JSON Object to Disk
Problem
Solution
How It Works
14-5. Reading JSON from an Input Source
Problem
Solution
How It Works
Parsing Content
14-6. Converting Between JSON and Java Objects
Problem
Solution
How It Works
14-7 Custom Mapping with JSON-B
Problem
Solution
How It Works
14-8. Replacing a Specified Element in a JSON Document
Problem
Solution
How It Works
Chapter 15: Jakarta Security
15-1. Setting Up Application Users and Groups in GlassFish
Problem
Solution
How It Works
15-2. Performing Basic Web Application Authorization
Problem
Solution #1
Solution #2
How It Works
15-3. Developing a Programmatic Login Form with Custom Authentication Validation
Problem
Solution
Creating the Login Form
Coding the Authentication Backend
Jakarta Enterprise Beans (Custom Solution)
Jakarta Server Faces Controller
User Entity
How It Works
15-4. Authentication with the Security API Using Database Credentials
Problem
Solution
How It Works
15-5. Managing Page Access Within a Jakarta Server Faces Application
Problem
Solution
How It Works
15-6. Configuring LDAP Authentication Within GlassFish
Problem
Solution
How It Works
15-7. Configuring Custom Security Certificates Within GlassFish
Problem
Solution
How It Works
Chapter 16: Concurrency and Batch
16-1. Creating Resources for Processing Tasks Asynchronously in an Application Server
Problem
Solution #1
Solution #2
How It Works
16-2. Configuring and Creating a Reporter Task
Problem
Solution
How It Works
16-3. Running More Than One Task Concurrently
Problem
Solution
How It Works
16-4. Utilizing Transactions Within a Task
Problem
Solution
How It Works
16-5. Running Concurrent Tasks at Scheduled Times
Problem
Solution
How It Works
16-6. Creating Thread Instances
Problem
Solution
How It Works
16-7. Creating an Item-Oriented Batch Process
Problem
Solution
How It Works
Chapter 17: Jakarta NoSQL
17-1. Configuring for Jakarta NoSQL
Problem
Solution
How It Works
17-2. Writing a Query for a Document Database
Problem
Solution
How It Works
17-3. Inserting, Updating, and Deleting from a Document-Oriented Database
Problem
Solution
Inserting
Updating
Deleting
How It Works
17-4. Working with a Key-Value Database
Problem
Solution
How It Works
Chapter 18: Jakarta EE Application Server
18-1. Installing GlassFish and Starting Up
Problem
Solution
How It Works
18-2. Changing the Administrator User Password
Problem
Solution
18-3. Deploying a WAR File
Problem
Solution
How It Works
18-4. Adding a Database Resource
Problem
Solution
How It Works
18-5. Adding Forms-Based Authentication
Problem
Solution
How It Works
18-6. Deploying a Microservice to GlassFish
Problem
Solution
How It Works
Chapter 19: Deploying to Containers
19-1. Creating a Docker Image and Running Java
Problem
Solution
How It Works
19-2. Deploying Images to Payara Server Utilizing an Official Payara Docker Image
Problem
Solution
How It Works
19-3. Creating a Docker Container Running a Basic Jakarta EE Application
Problem
Solution
How It Works
19-4. Enabling Communication Between Containers
Problem
Solution
How It Works
Appendix A: Jakarta EE Development with Apache NetBeans IDE
A-1. Configuring Application Servers Within NetBeans
Developing Java Web or Enterprise Applications
A-2. Creating a NetBeans Java Web Project
A-3. Creating Jakarta Server Faces Application Files
A-4. Developing Entity Classes
A-5. Using Jakarta Persistence Query Language
A-6. Using HTML5
Index
📜 SIMILAR VOLUMES
<p><span>Take a problem-solution approach for programming enterprise Java or Java EE applications and microservices for cloud-based solutions, enterprise database applications, and even small business web applications. </span><span>Java EE to Jakarta EE 10 Recipes</span><span> provides effective, pr
<p><em>Java EE 7 Recipes</em> 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, <em>Java EE 7 Recipes</em> provides effective and proven solutions to accom
<span><p>Quickly find solutions to dozens of common programming problems with the Java Enterprise Edition Platform for small business web applications, enterprise database applications, and microservices solutions. Content is presented in the popular problem-solution format. Look up the programming
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
Take a problem-solution approach to programming enterprise Java applications and microservices for cloud-based solutions, enterprise database applications, and even small business web applications. This book provides effective and proven code snippets that you can immediately use to accomplish just