Modify DukesBirthdayRemote.java
Expand the firstcup-ejb module in the Projects pane.
Double-click DukesBirthdayRemote.java under Source Packages->com.sun.firstcup.ejb.
Right-click in the editor window and select Fix Imports.
Select java.util.Date as the fully-qualified class name of the Date class and click OK.
Remove the throws clause from the method definition so that you are left with int getAgeDifference(Date date);.
Select File->Save.
Creating the Web Client
To create the web client, you need to perform the following tasks:
Set the firstcup-war module to support JavaServer Faces technology. This will create a web.xml file that has a mapping to FacesServlet.
Create a web service client.
Create a resource bundle to hold localized messages used by the JSP pages.
Configure the resource bundle in the configuration file.
Create the DukesBDay managed bean class.
Configure DukesBDay in the configuration file.
Create the greeting.jsp page.
Configure the navigation rules in the configuration file.
Create the response.jsp page.
Setting firstcup-war to support JavaServer Faces Technology
All JavaServer Faces applications must include a mapping to the FacesServlet instance in their deployment descriptors. The FacesServlet instance accepts incoming requests, passes them to the life cycle for processing, and initializes resources.
You create the mapping to FacesServlet in the web application's deployment descriptor. Rather than adding the mapping to the web.xml file directly, NetBeans will create the web.xml file and perform the mapping to FacesServlet for you when you specify that your web application supports JavaServer Faces technology. To do this, perform the following task.
Setting firstcup-war to support
JavaServer Faces technology
Right-click the firstcup-war module of the firstcup enterprise application in the Projects pane.
Select Properties from the popup menu.
Select Frameworks from the Categories tree.
Click Add.
Select JavaServer Faces from the list of choices in the dialog.
Click OK.
Change the servlet URL mapping to /firstcupWeb/*.
This path will be the path to the FacesServlet instance. All requests must include this path in between the application's context path and the page in the URL. Users don't have to include this path in the URL because firstcup includes an index.jsp page that forwards users to the greeting.jsp page when they enter the following URL:
http://localhost:8080/firstcup
De-select the Validate XML checkbox.
Click OK.
The remaining steps tell you how to perform the forward to greeting.jsp from the index.jsp page.
Expand the firstcup-war module in the Projects pane and double-click Web Pages.
Right-click welcomeJSF.jsp, select Delete from the popup menu, and click Yes in the dialog.
Double-click index.jsp.
NetBeans generated this file when you created the firstcup project.
Delete everything on the page.
Enter the following in the index.jsp page:
<jsp:forward page="/firstcupWeb/greeting.jsp"/>
Save the file by selecting File -> Save from the menu bar.
Creating a Web Service Client for the firstcup-war Web Module
The firstcup-war web module must consume the firstcup-dukes-age web service in order to get Duke's current age. For this to happen, you need to create a web service client for the firstcup-war web module.
Creating a Web Service Client for the firstcup-war
Web Module
Select firstcup-war from the Project pane.
Select File -> New File.
Select Web Services from the Categories pane.
Select Web Service client from the File Types pane.
Click Next.
Select WSDL URL.
Into the WSDL URL field, enter the following location of the WSDL file of the web service that the web service client will consume.
http://localhost:8080/DukesAgeService/DukesAgeService?WSDL
Into the Package field, enter the following package where the client files will be generated.
com.sun.firstcup.webservice
Click Finish.

Previous