< Previous | Next >

Lesson 4: Deploy your application

Lesson 4 leads you through the creation of a JSP and a Faces JSP to test your application.
Before you begin, you must complete Lesson 3: Create a Java method.
In this lesson, you :
  1. To create a JSP, click File > New > Other > J2C.
  2. In the Select a wizard page, select Web Page, Web Service, or EJB from J2C Java bean, and click Next.
  3. In the J2C Java bean selection page, click Browse.
  4. In the Find J2C bean page, type an asterisk (*) in the Select entries field.
  5. In the Matching types field, select PhoneBookImpl.
  6. Click OK.
  7. In the J2C Java bean selection page, click Next.
  8. In the Deployment Information page, select Simple JSP.
  9. Click Next.
  10. In the JSP Creation page, select Generate simple JSPs with default input fields.
  11. In the JSP folder field, enter a JSP Folder name, such as SampleJSP.
  12. Click Finish.
  13. Next you run your JSP: Right-click TestClient.jsp and select Run on Server.
  14. A browser window with the Test Client launches. Click runPhoneBook method.
  15. Use the following values as Inputs:
    • Type IVTNO in the In__trcd field.
    • Type 0 in the In___zz field.
    • Type LAST1 in the In__name1 field.
    • Type DISPLAY in the In__cmd field.
    • Type 59 in the In__ll field.
  16. Click Invoke, and this output appears in the Result field.

    test1

  17. Now submit another command to add a phone book entry. Click runPhoneBookmethod.
  18. Use the following values as Inputs:
    • Type 59 in the In__ll field.
    • Type 0 in the In___zz field.
    • Type IVTNO in the In__trcd field.
    • Type Add in the In__cmd field.
    • Type Jane in the In__name2 field.
    • Type Doe in the In__name1 field.
    • Type 55555 in the In__zip field.
    • Type 5-5555 in the In__extn field.
  19. Click Invoke, and this output appears in the Result field.

    test2

  20. Now submit another command to display the phone book entry you just added. Click runPhoneBook method.
  21. Use the following values as Inputs:
    • Type 59 in the In__ll field.
    • Type IVTNO in the In__trd field.
    • Type 0 in the In___zz field.
    • Type DISPLAY in the In__cmd field.
    • Type Doe in the In__name1 field.
    • Type 93 in the size field.
  22. Click Invoke, and this output appears in the Result field.

    test3

  23. Now you creates a Faces JSP to deploy the J2C Java bean:
  24. Expand the IMSPhoneBook project, and find the WebContent folder.
  25. Right click WebContent folder in your IMSPhoneBook project and select New > Other > Web > Faces JSP file.
  26. Type Test in the Name field.
  27. Accept defaults for all other fields.
  28. Click Finish.
  29. Next you add the Java bean to faces JSP: Once you have created the Faces JSP file, the page should open Test.jsp in the Design page. If the workspace does not open in the Design page of the editor, expand the WEB-INF folder under the WebContent folder. Right click Test.jsp, select Open With, and click Page Designer. Test.jsp opens in the Design page.
  30. The Palette view appears on the right panel. If it does not appear, in the top menu, click Window > Show view > Palette.
  31. In the Datafolder of the Palette view, click the JavaBean option of the Palette.
  32. Drag the JavaBean to the Test.jsp editor; the Add JavaBean wizard opens
  33. Select Add new JavaBean.
  34. In the Name field, type phonebookLookup.
  35. Click the open book icon, open book, beside the Class field. The Class Selection window appears.
  36. In the Class Selection page, type PhoneBookImpl in the Search field.
  37. Clear the Add input/output controls to display the JavaBean on the Web page check box.
  38. Click Finish.
  39. You see PhoneBookImpl in the Page Data view.
  40. Adding input and output controls to the faces JSP: Right-click phonebookLookup Java Bean in the Page Data view, and click Add New JavaBean Method.
  41. From the list of available methods, click runPhoneBook.
  42. Click OK.
  43. Expand phonebookLookup Java Bean in the Page Data view, and select the runPhoneBook() method.
  44. Drag the runPhoneBook() method onto the editor. The Insert JavaBean wizard appears.
  45. In the Create controls for: field, select Inputting data.
  46. In the Fields to display field, select None, to clear the form.
  47. In the Fields to display field, select these input fields
    • arg.in__trcd
    • arg.in__zz
    • arg.size
    • arg.in__name1
    • arg.in__cmd
    • arg.in__ll
  48. Click Finish.
  49. Accept defaults for the other fields.
  50. Click Next.
  51. In the Configure Data Controls page, select Create controls for displaying the results.
  52. In the Fields to display field, select None, to clear the form.
  53. In the Fields to display field, select these output fields
    • out__zz
    • out__zip
    • out__extn
    • out__msg
    • out__cmd
    • out__ll
    • out__name2
    • out__name1
    • size
  54. Click Finish.
  55. Save your Faces JSP page, by pressing Ctrl-S or by clicking File > Save in the toolbar.
  56. Now you test the Faces web page: Select the Servers tab. Start the test server, if it is not already running. To start the server, right click the WebSphere Application Server v8.0 or 7.x and click Start.
  57. Right click Test.jsp (the faces JSP that you created) in the Project Explorer view, and select Run < Run on Server.
  58. Select WebSphere Application Server v8.0 or 7.x and click Finish.
  59. The browser opens to Test.jsp. Use the following values as Inputs:
    • Type IVTNO in the In__trcd field.
    • Type 59 in the In__ll field.
    • Type 0 in the In___zz field.
    • Type DISPLAY in the In__cmd field.
    • Type LAST1 in the In__name1 field.
    • Type 93 in the size field.
    Note: Ensure that there are no extra spaces in the text box before your entry.
  60. Click Submit.
  61. You can see the output displayed in your browser.
You have completed the PhoneBook tutorial.
< Previous | Next >

Feedback