Document Information


1.  Introduction

2.  The Java Platform, Enterprise Edition

3.  Creating Your First Java EE Application

Coding the Example Application

Getting Started

Register the Server with NetBeans IDE

Create a Directory for the Example

Specify Some Settings

Creating the Web Service Endpoint

JAX-WS Endpoints

Creating the Endpoint

Building and Deploying the Web Service

Creating the Enterprise Bean

Creating DukesBirthdayBean in NetBeans IDE

Creating the Web Client

Setting firstcup-war to Support JavaServer Faces Technology

Creating a Web Service Client for the firstcup-war Web Module

Creating a Resource Bundle

Configuring the Resource Bundle in the Configuration File

Adding a Dependency on the Enterprise Bean Module

Creating the DukesBDay Managed Bean Class

Configuring the DukesBDay Bean in the Configuration File

Creating the greeting.jsp Page

Creating an Empty JSP Page

Declaring the JavaServer Faces Tag Libraries

Adding the f:view and f:form Tags

Adding Output Labels to Display Read-only Content

Adding an Input Component to Accept the User's Birth Date

Registering a Converter on the Input Component

Adding an Error Message to Display if Conversion Fails

Adding a Button for Submitting the Form

Defining Page Navigation

Creating the response.jsp Page

Building, Packaging, Deploying, and Running the firstcup Enterprise Application

Preparing the Deployment Descriptor

Building and Packaging the firstcup Enterprise Application

Deploying the firstcup Enterprise Application

Running the firstcup Application

4.  Building, Packaging, and Deploying and Running the Example Application

5.  Next Steps


Architecture of the Example Application

The example application consists of three main components: DukesAgeService, a web service endpoint; DukesBirthdayBean, an enterprise bean; and firstcup, a web application created with JavaServer Faces technology.

DukesAgeService is a JAX-WS endpoint that calculates the age of Duke, the Java mascot. Duke was born on May 23, 1995, when the first demo of Java technology was publicly released.

DukesBirthdayBean is a stateless session bean that calculates the difference between the user's age and Duke's age.

The firstcup web application is a JavaServer Faces application that accesses DukesAgeService to display Duke's age, reads in a date provided by the user, accessesDukesBirthdayBean to calculate who is older, and then displays the difference in years between the user and Duke.

The web application consists of the following:

  • greeting.jsp: A JSP page with which a user can enter a date.

  • response.jsp: A JSP page that tells the user whether he or she is older or younger than Duke, based on the date the user entered in the greeting.jsp page.

  • A JavaServer Faces managed bean that defines properties to hold the user's birth date, get Duke's current age from the web service, and get the age difference between the user and Duke from the enterprise bean.

  • faces-config.xml: A file used to configure resources for the JavaServer Faces application. In the case of this application, the file configures a resource bundle containing messages, the managed bean, DukesBDay, and the page navigation rules.

  • web.xml: The web application's deployment descriptor, which is used to configure certain aspects of a web application when it is installed. In this case, it is used to provide a mapping to the application's FacesServlet instance, which accepts incoming requests, passes them to the life cycle for processing, and initializes resources.

Tiers in the Example Application

The example application has one web tier component (the firstcupweb client) and two business tier components (the DukesAgeServiceweb service and the DukesBirthdayBeanenterprise bean). The user's web browser is the client tier component, as it accesses the rest of the application through the web tier. The example application does not access the EIS tier.

Java EE Technologies Used in the Example Application

The DukesAgeService web service endpoint is a JAX-WS endpoint The DukesBirthdayBean enterprise bean is a stateless session bean. The firstcupweb client is a JavaServer Faces application that runs in the web container of the Java EE server.