Exercise 1.4: Deploying the application

Before you begin, you must complete Exercise 1.3: Creating the Java method.

Creating a JSP

  1. Click File > New > Other.
  2. In the Select a wizard page, select Web Page, Web Service, or EJB from J2C Java bean.
  3. Click Next.
  4. In the J2C Java bean selection page, click Browse.
  5. In the Find J2C bean page, type an asterisk (*) in the Select entries field.
  6. In the Matching types field, select CustomerImpl.
  7. Click OK.
  8. In the J2C Java bean selection page, click Next.
  9. In the Deployment Information page, select JSP.
  10. Click Next.
  11. In the JSP Creation page, select Generate simple JSPs with default input modes.
  12. In the JSP folder field, enter a JSP Folder name, such as SampleJSP. Click Finish.

Running your JSP

  1. Once the bean has been generated, you can run it on WebSphere Application Server. In the J2EE perspective, open Servers view, and right click New > Server.
  2. Select WebSphere V6. Server. Click Next
    Note: If you do not see the WebSphere V6. Server option, change the View by option to Name to view the options.
  3. Accept the default port number; if it is already in use, modify port settings if needed. Click Next.
  4. Select IMSPhoneBookEAR from Available projects. Click Add.
  5. Click Finish.
  6. Start the server.
  7. When the server is successfully started, right-click TestClient.jsp and select Run on Server.
  8. A browser window with the Test Client will launch. Click on runPhoneBook method.
  9. Use the following values as Inputs:
  10. Click Invoke, and this output will appear in the Result field.
  11. runPhoneBook method output

  12. Now submit another cmd to add a phone book entry. Click on runPhoneBook method.
  13. Click Invoke, and this output will appear in the Result field.
  14. runPhoneBook method output

  15. Now submit another cmd to display the phone book entry you just added. Click on runPhoneBook method.
  16. Click Invoke, and this output will appear in the Result field.
  17. runPhoneBook method output

Creating a Faces JSP to deploy the J2C Java bean

This section outlines the steps for deploying your J2C Java bean through a faces JSP.

  1. Expand the IMSPhoneBook project, and find the WebContent folder.
  2. Right click on WebContent folder in your IMSPhoneBook project and select New > Other > Web > Faces JSP file.
  3. Give your new new faces JSP the name Test.
  4. Accept defaults for all other fields.
  5. Click Finish.

Adding the java bean to faces JSP

  1. Once you have created the Faces JSP file, the page should open Test.jsp in the Design page. If it is not in the Design page of the editor, expand the WEB-INF folder under the WebContent folder. Right click on Test.jsp, click Open With, and click on Page Designer. Test.jsp will open in the Design page.
  2. The Palette view should appear on the right panel. If it does not appear, in the top menu, click on Window > Show view > Palette.
  3. In the Data folder of the Palette view, click on the JavaBean option of the Palette
  4. Drag and drop the JavaBean to the Test.jsp editor; the Add JavaBean wizard will open.
  5. Select Add new JavaBean.
  6. In the Name field, type phonebookLookup
  7. Click the open book icon, book icon, beside the Class field.
  8. The Class Selection window appears.
  9. In the Class Selection page, type PhoneBookImpl in the Search field
  10. Clear the Add input/output controls to display the JavaBean on the Web page check box.
  11. Click Finish.
  12. You will see PhoneBookImpl in the Page Data view.

Adding input and output controls to the faces JSP

  1. Right-click phonebookLookup Java Bean in the Page Data view, and click Add New JavaBean Method.
  2. From the list of available methods, click on runPhoneBook .
  3. Click OK.
  4. Expand phonebookLookup Java Bean in the Page Data view, and select the runPhoneBook() method.
  5. Drag and drop the runPhoneBook() method onto the editor. The Insert JavaBean wizard appears.
  6. In the Create controls for: field, select Inputting data.
  7. In the Fields to display field, select None, to clear the form.
  8. In the Fields to display field, select these input fields
  9. Click Finish.
  10. Accept defaults for the other fields.
  11. Click Next.
  12. In the Configure Date Controls page, select Create controls for displaying the results.
  13. In the Fields to display field, select None, to clear the form.
  14. In the Fields to display field, select these output fields
  15. Click Finish.
  16. Save your Faces JSP page, by pressing Ctrl-S or by clicking File > Save in the toolbar.

Testing the Faces JSP

  1. Select the Servers tab. Start the test server, if it is not already running. To start the server, right click on the WebSphere Application Server v6.0, and click Start.
  2. Right click on Test.jsp (the faces JPS that you just created) in the Project Explorer view.
  3. Select Run < Run on Server.
  4. Select WebSphere Application Server v6.0 and click Finish
  5. The browser will open to Test.jsp. Type these values in the text boxes:

    Note:Ensure that there are no extra

    FacesJSP output

  6. Click Submit.
  7. You will see the output displayed in your browser.

Congratulations! You have completed the PhoneBook Tutorial.

Finish your tutorial by reviewing the materials in the Summary.

Terms of use | Feedback

(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.