Using JSP files for a Web interaction

You can use the Web Interaction wizard to create a Web interaction for JSP files that you created in your Web project. The wizard adds coding within the JSP files, and generates Java classes used to communicate with your business processes.

To open the Web Interaction wizard, select the Web project folder, then click the Create or Modify a Web interaction icon Toolbar icon for Create or Modify a Web interaction. on the toolbar. If you have not defined run-time information in the iSeries Web Tools Run-time Configuration wizard, you will receive a warning message in the first page of the Web Interaction wizard.

As you progress through the Web Interaction wizard, the options you select determine which pages of the wizard are displayed.

When you use JSP files that you created, the pages in the wizard that you work with are:
  1. Specify a Name and Location for your Web Interaction
  2. Specify the Input and Output Pages for your Web Interaction
  3. One of:
    1. Specify the Input and Output Parameters for your iSeries Host Program
    2. Choose the Java Bean and Methods to Invoke
  4. Map and Link the Input Parameters to the Input Fields
  5. Map and Link the Output Parameters to the Output Fields

The following information describes how to complete the wizard pages:

  1. Specify a Name and Location for your Web Interaction

    See Interaction name and location for descriptions of the fields on this page of the wizard.

    1. The Destination folder defaults to the Web content folder in your Web project. You can use the Browse button to select another folder, but it must be within the WebContent folder.
    2. Enter a name for your Web interaction in the Web Interaction name field.
    3. The Java package prefix is com.ibm followed by your Web project name. You can change this package prefix, and if the package does not exist in the Web project, the Web Interaction wizard creates it for you.
    4. By default, the Use error page option is selected. This option indicates that the error.jsp file that is copied into your Web project by the wizard, is used to display run-time errors that occur when you run your Web application.
    5. You can select the Invalidate session after the interaction occurs option if this is the last interaction. The program or procedure can then perform any clean up operations that are required. When the program or procedure ends, the session is invalidated and the iSeries job terminates.
    6. Select Terminate iSeries connection to terminate the connection to the iSeries system after the interaction occurs. This option and Invalidate session after the interaction occurs are mutually exclusive. If you select one, you cannot select the other.
    7. Click Next to proceed to the next page in the wizard.
  2. Specify the Input and Output Pages for your Web Interaction

    See Input and output pages for descriptions of the fields and controls on this page of the wizard.

    1. Select the radio button Use input pages, click Add, browse and select the JSP file in your Web project that you want to use as the input page for the Web interaction. Click OK to add the file.
    2. Select the radio button for Use output pages, click Add, browse to and select the JSP file in your Web project that you want to use as the output page for the Web interaction. Click OK to add the file.
    3. Click Next to proceed to Specify the Input and Output Parameters for your iSeries Host Program.
  3. Specify the Input and Output Parameters for your iSeries Host Program

    See iSeries program or procedure for descriptions of the fields and controls on this page of the wizard.

    The Use an iSeries program or procedure radio button is selected when you reach this page in the wizard. If you select the Use Java bean and Methods radio button, the page changes to a different set of options. See Choose the Java Bean and Methods to Invoke for information about selecting the options on this page. If you select the No Program Call radio button a different wizard page opens. See No Program Call for information about this page.

    1. By default, the Add Program fields are shown. You can define the program call definitions the following ways:
      • Add them manually using the steps described below, by completing the Add Program, Add Parameter, and Add Structure pages.
      • If you have a PCML file or the source file for the program or procedure that you want to call, click the Import PCML button to import the PCML file or have the wizard create the PCML file and import it for you.

      Use the Add Program fields on this page in the wizard to define the name and location of the program object or service program object that performs the business logic for the Web interaction. The program, or service program can already exist on your iSeries host, or you can code and compile the program objects later. See Add program for descriptions of the fields and controls that you can use on this page.

    2. When you complete the definition of your program or service program, click OK to add the program definition to the Program call definitions area of the page. When you click OK the Add Parameter fields are automatically displayed.
    3. Use the Add Parameter fields on this page in the wizard to define the parameters whose equivalents are in your program or service program. See Add parameter for descriptions of the fields and controls that you can use on this page.
    4. After you complete the definitions for a parameter, click OK to add the parameter definition to the program in the Program call definitions area. The Add Parameter fields are cleared and are available for another parameter definition.
    5. Click the Add Structure button to define a structure that you can use with your program or service program call definition. See Add structure for descriptions of the fields and controls that you can use on this page.

      You can explicitly add parameters to the structure, or you can add parameters to a structure from fields defined within records on an iSeries host, see Populating a structure with field definitions.

    6. Click OK to add the structure definition to the Program call definitions area on this page of the wizard.
    7. To add the structure that you defined to your program definition as a parameter:
      1. Select the program name in the Program call definitions area and click the Add Parameter button, or right-click and select Add Parameter.
      2. Enter a parameter name that represents the structure.
      3. Select structure in the Data type list, select a structure in the Structure name field, then select a usage in the Usage field and click OK.
  4. Choose the Java Bean and Methods to Invoke

    This page opens in the wizard when you select the Use a Java bean radio button instead of the Use an iSeries program or procedure radio button.

    See Java bean and methods for descriptions of the fields and controls on this page of the wizard.

    1. Click Browse to open the Choose Java bean window, and begin typing the name of a Java bean in the top field. As you type, the Matching types field is populated with the Java bean names that correspond to your input.
    2. Select the Java bean that you want to use and click OK to add it to the Bean field and to list the properties and methods for the bean in the field. All inherited methods and properties are also listed.
    3. Select the properties and methods that you want to use for the business logic in this interaction and click Next to open the Map and Link the Input Parameters to the Input Fields page of the wizard.
  5. Map and Link the Input Parameters to the Input Fields

    See Map and link input parameters to input fields for descriptions of the fields and controls on this page of the wizard.

    This page of the wizard shows the input page fields that you added to your JSP file, and the input parameters that you defined for your program or service program, or the Java bean methods that are available as input parameters. The properties and values for each of these are displayed in the bottom areas of the wizard page when you click on a field or a parameter.

    1. In the Input page fields area, click the plus icons to expand the JSP file and the Form to display the input fields that you defined for the JSP file.
    2. For each input field, determine the parameter that you want to link it to, select the field in the Input page fields area, select the parameter in the Input parameters area, and then click Link. For Java bean properties and methods, the ones you select determine which are prompted for on the input page.
    3. Repeat the previous step for the input fields and the input parameters that you want to link.
    4. When you complete linking fields and parameters, click Next to open the Map and Link the Output Parameters to the Output Fields page.
  6. Map and Link the Output Parameters to the Output Fields

    See Map and link output parameters to output fields for descriptions of the fields and controls on this page of the wizard.

    This page of the wizard shows the output parameters that you defined for your program or service program, or the Java bean methods that are available as output parameters, and the output page fields that you added to your JSP file. The properties and values for each of these are displayed in the bottom areas of the wizard page when you click on a field or a parameter.

    1. In the Output page fields area, click the plus icons to expand the JSP file and the Form to display the output fields that you defined for the JSP file.
    2. For each output field, determine the output parameter that you want to link it to, select the parameter in the Output parameters area, select the field in the Output page fields area, and then click Link. For Java beans methods, the ones you select determine which are shown on the output page.
    3. Repeat the previous step for the output parameters and the output fields that you want to link.
  7. Create the Web interaction
    1. Click Finish to create the Web interaction, to update the JSP files, and to create Java classes used to communicate with the program, or procedure. For Java bean methods and properties, code is generated to set the properties and call the methods for your Web interaction.
    Tip: Each Web interaction is represented by a .wit file in your Web project. To modify a Web interaction, double-click the .wit file to open the Web Interaction wizard and modify the settings for the interaction.
    Restriction: The names of the PCML file and the MPCML file generated by the Web Interaction wizard are the same as the Web project name. For example, if the Web project name is myproj, then the PCML file that is generated is myproj.pcml. Similarly, the name of the MPCML file is myproj.mpcml.
    • If you create a new Web project and then import all of the files, including the PCML and MPCML files, from another Web project, the name of the PCML and MPCML files no longer match the name of the new Web project. As a result, the Web application fails to run correctly. You must rename the PCML and MPCML files to match the Web project name to resolve this problem.
    • If you rename an existing Web project, be sure to rename the PCML and the MPCML files to match the new Web project name.