Exercise 1.4: Deploying the application

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

Creating a JSP

  1. In the Deployment Information page, select Create J2EE resource.
  2. In the J2EE Resource Type, select JSP. Click Next.
  3. In the JSP Creation page, select Generate simple JSPs with default input modes.
  4. In the JSP folder field, enter a JSP Folder name. Click Finish.
  5. In the J2EE perspective, open Servers view, Right click New > Server.
  6. Select WebSphere Application Server V6 Server. Click Next
    NOTE: If you do not see the WebSphere Application Server V6 Server, go to the View by field, and select name.
  7. Accept the default port number; if it is already in use, modify the port settings.
  8. Click Next.
  9. Select CustomerProjEAR from Available projects. Click Add.
  10. Click Finish.
  11. Start the server.
  12. When server is successfully started, right click on TestClient.jsp and select Run on Server.
  13. A browser window with the Test Client will be launched. Click on the getCustomer method.
  • Click Invoke. The customer information will appear in the output console.

    getCustomer 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 CustomerProj project, and find the WebContent folder.
    2. Right click on WebContent folder in your CustomerProj project and select New > Other > Web > Faces JSP file.
    3. Give your new faces JSP the name Test.
    4. Accept defaults for all other fields.
    5. Click Finish.

    Adding the Java bean to a Faces JSP

    1. Once you have created the Faces JSP file, the page should open Test.jsp in the Design page of the editor. If it is not in the Design page, 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 of the editor.
    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 JavaBean option of the Palette.
    4. Drag and drop the JavaBean to the Test.jsp Design window; the Add JavaBean wizard will open.
    5. Select Add new JavaBean.
    6. In the Name field, type customerLookup.
    7. Click the open book icon, book icon, beside the Class field.
    8. The Class Selection dialog will appear. Type CustomerImpl in the search field and click on the found class. Click OK.
    9. In the Class Selection page, type CustomerImpl in the Search field
    10. Uncheck Add input/output controls to display the JavaBean on the web page.
    11. Click Finish.
    12. You will see CustomerImpl in the Page Data view.

    Adding input and output controls to the Faces JSP

    1. Right click on customerLookup Java Bean in the Page Data view, and click Add New JavaBean Method.
    2. From the list of available methods, click on getCustomer .
    3. Click OK.
    4. Expand customerLookup Java Bean in the Page Data view, and select the getCustomer() method.
    5. Drag and drop the getCustomer() method onto the JSP's canvas.
    6. The Insert JavaBean wizard will appear. The Configure Date Controls page allows you to select data fields.
    7. In the Create controls for: field, select Inputting data.
    8. In the Fields to display field, select None, to clear the form.
    9. In the Fields to display field, select the field that has the label arg.customerNumber..
    10. Accept defaults for other fields.
    11. Click Next.
    12. In the Configure Data 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 the output fields LastName, FirstName, Street, and PostalCode.
    15. Click Finish.
    16. Save your Faces JSP 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 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. In the CustomerNumber field, type 12345.

      Faces JSP output

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

      Faces JSP output

    Testing the application using the TestCustomer program

    You can run the application directly using the TestCustomer.java file. You pass in a CustomerNumber, and the corresponding CustomerInfo will be returned.

    1. Expand the CustomerProj > Java Resources > JavaSource.
    2. Right click on the sample.cics package.
    3. Select New > class.
    4. Type TestCustomer in the Name field.
    5. In the Java editor window, replace all the code in your workspace with the following code:

      TestCustomer.java
      /*******************************************************************************
       * Licensed Materials - Property of IBM
       *  
       * com.ibm.j2c.cheatsheet.content
       *  
       * Copyright IBM Corporation 2004. All Rights Reserved. 
       * 
       * Note to U.S. Government Users Restricted Rights:  Use, duplication or disclosure restricted by GSA ADP  Schedule Contract with IBM Corp. 
       *******************************************************************************/
      /*
       * Created on Aug 30, 2004
       *
       * TODO To change the template for this generated file go to
       * Window - Preferences - Java - Code Style - Code Templates
       */
      package sample.cics;
      import sample.cics.data.*;
      
      /**
       * @author ivyho
       *
       * TODO To change the template for this generated type comment go to
       * Window - Preferences - Java - Code Style - Code Templates
       */
      public class TestCustomer {
      
      	public static void main(String[] args) {
      		
      		try {
      			
      			
      			CustomerInfo input = new CustomerInfo();
      			input.setCustomerNumber("12345");
      		
      			CustomerImpl proxy = new CustomerImpl();
      			CustomerInfo output = proxy.getCustomer(input);
      			System.out.println("\nCustomerNo:"+output.getCustomerNumber()+"\ncustomer First Name:"+output.getFirstName()+"\ncustomer Last Name:"+ output.getLastName()+ "\nAddress:" +output.getStreet()+" \nCity:" + output.getCity()+" \nCountry:"+output.getCountry() +" \nphone:"+output.getPhone());
      			
      				
      			 input.setCustomerNumber("44444");
      		
      			 proxy = new CustomerImpl();
      			 output = proxy.getCustomer(input);
      					
      			 System.out.println("\nCustomerNo:"+output.getCustomerNumber()+"\ncustomer First Name:"+output.getFirstName()+"\ncustomer Last Name:"+ output.getLastName()+ "\nAddress:" +output.getStreet()+" \nCity:" + output.getCity()+" \nCountry:"+output.getCountry() +" \nphone:"+output.getPhone());
      				
      			
      		}catch (Exception e)
      		{
      			e.printStackTrace();
      		}
      		
      		
      		
      		
      	}
      }
      
      
    6. In the Project Explorer view, right click on the TestCustomer.java file. Select Run > Run As Application.
    7. You will see the following in the console:

      TestCustomer method output

      Congratulations! You have completed the CICS Taderc99 Tutorial.

    Finish your tutorial by reviewing the materials in the Summary.

    Terms of use | Feedback

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