The example application consists of three main components: DukesAgeResource, a JAX-RS RESTful web service; DukesBirthdayBean, an enterprise bean; and firstcup, a web application created with JavaServer Faces Facelets technology.
DukesAgeResource is a JAX-RS resource 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 Facelets application that accesses DukesAgeResource to display Duke's age, reads in a date provided by the user, accesses DukesBirthdayBean to calculate who is older, and then displays the difference in years between the user and Duke.
The firstcup web application consists of the following:
greeting.xhtml: An XHTML page that uses the JavaServer Faces Facelets tag libraries. Users can enter their birth date in a field and submit it for comparison against Duke's birth date.
response.xhtml: A Facelets-enabled XHTML 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.xhtml page.
DukesBDay.java: 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.
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.
WebMessages.properties and WebMessages_es.properties: Java programming language properties files that contain the localized strings used in greeting.xhtml and response.xhtml. By default, the English language strings in WebMessages.properties are used, but Spanish language strings are also provided in WebMessages_es.properties.
DukesBirthdayBean.java: A local, no-interface view stateless session enterprise bean packaged within the firstcup application. DukesBirthdayBean calculates the difference between the user's birthday and Duke's birthday.
The example application has one web tier component (the firstcup web client) and two business tier components (the DukesAgeResource web service and the DukesBirthdayBean enterprise 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.
The DukesAgeResource web service is a JAX-RS resource. The DukesBirthdayBean enterprise bean is a stateless session bean. The firstcup web client is a JavaServer Faces application that runs in the web container of the Java EE server.