Exercise 1.4: Deploying the application
Before you begin, you must complete Exercise 1.3: Creating the Java method.
Creating a JSP
- In the Deployment Information page, select Create J2EE resource.
- In the J2EE Resource Type, select JSP. Click Next.
- In the JSP Creation page, select Generate simple JSPs with default input modes.
- In the JSP folder field, enter a JSP Folder name, such as SampleJSP. Click Finish.
- 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.
- 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.
- Accept the default port number; if it is already in use, modify port settings if needed. Click Next.
- Select IMSPhoneBookEAR from Available projects. Click Add.
- Click Finish.
- Start the server.
- When the server is successfully started, right-click TestClient.jsp and select Run on Server.
- A browser window with the Test Client will launch. Click on runPhoneBook method.
- Use the following values as Inputs:
- Enter IVTNO in In__trcd
- Enter 0 in the In___zz field
- Enter LAST1 in In__name1 field
- Enter DISPLAY in In__cmd field
- Enter 59 in In__ll field
- Enter 93 in size field
- Click Invoke, and this output will appear in the Result field.
- Now submit another cmd to add a phone book entry. Click on runPhoneBook method.
- Enter 59 in In__ll field
- Enter 0 in the In___zz field
- Enter IVTNO in In__trcd
- Enter Add in In__cmd field
- Enter Jane in In__name2 field
- Enter Doe in In__name1 field
- Enter 55555 in In__zip
- Enter 5-5555 in In__extn
- Enter 93 in the size field
- Click Invoke, and this output will appear in the Result field.
- Now submit another cmd to display the phone book entry you just added. Click on runPhoneBook method.
- Enter 59 in In__ll field
- Enter IVTNO in In__trd
- Enter 0 in the In___zz field
- Enter DISPLAY in In__cmd field
- Enter Doe in In__name1 field
- Enter 93 in the size field
- Click Invoke, and this output will appear in the Result field.
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.
- Expand the IMSPhoneBook project, and find the WebContent folder.
- Right click on WebContent folder in your IMSPhoneBook project and select New > Other > Web > Faces JSP file.
- Give your new new faces JSP the name Test.
- Accept defaults for all other fields.
- Click Finish.
Adding 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 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.
- The Palette view should appear on the right panel. If it does not appear, in the top menu, click on Window > Show view > Palette.
- In the Data folder of the Palette view, click on the JavaBean option of the Palette
- Drag and drop the JavaBean to the Test.jsp editor; the Add JavaBean wizard will open.
- Select Add new JavaBean.
- In the Name field, type phonebookLookup
- Click the open book icon,
, beside the Class field. The Class Selection window appears.
- In the Class Selection page, type PhoneBookImpl in the Search field
- Clear the Add input/output controls to display the JavaBean on the Web page check box.
- Click Finish.
- You will see PhoneBookImpl in the Page Data view.
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.
- From the list of available methods, click on runPhoneBook .
- Click OK.
- Expand phonebookLookup Java Bean in the Page Data view, and select the runPhoneBook() method.
- Drag and drop the runPhoneBook() method onto the editor. The Insert JavaBean wizard appears.
- In the Create controls for: field, select Inputting data.
- In the Fields to display field, select None, to clear the form.
- 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
- Click Finish.
- Accept defaults for the other fields.
- Click Next.
- In the Configure Date Controls page, select Create controls for displaying the results.
- In the Fields to display field, select None, to clear the form.
- 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
- Click Finish.
- Save your Faces JSP page, by pressing Ctrl-S or by clicking File > Save in the toolbar.
Testing the Faces JSP
- 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.
- Right click on Test.jsp (the faces JPS that you just created) in the Project Explorer view.
- Select Run < Run on Server.
- Select WebSphere Application Server v6.0 and click Finish
- The browser will open to Test.jsp. Type these values in the text boxes:
- Enter IVTNO in In__trcd
- Enter 59 in In__ll field
- Enter 0 in the In___zz field
- Enter DISPLAY in In__cmd field
- Enter LAST1 in In__name1 field
- Enter 93 in size field
Note:Ensure that there are no extra
- Click Submit.
- 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.