Creating a Result Set

The following steps describe how you can add a scripting element to your page to call the getAllEmployees method and hold the result set data that is returned. This query is defined in the DataHandler class, and initialized in the page by using the jsp:useBean tag.

  1. Open the employees.jsp page in the Visual Editor. In the JSP part of the Component Palette, select Scriptlet and drag and drop it onto the JSP page next to the representation of the UseBean.
  2. In the Insert Scriptlet dialog box, enter the following lines of code, which will call the getAllEmployees method and produce a ResultSet object:
    ResultSet rset;
    rset = empsbean.getAllEmployees();
    

    Click OK. A representation of the scriptlet is displayed on the page as shown in Figure 4-9.

    Figure 4-9 Scriptlet Representation in a JSP Page

    Description of Figure 4-9 follows
    Description of "Figure 4-9 Scriptlet Representation in a JSP Page"
  3. Select the Source tab at the bottom of the Visual Editor to see the code that has been created for the page so far. A wavy line under ResultSet indicates that there are errors in the code.
  4. The Structure window on the left-hand side also indicates any errors in the page. Scroll to the top of the window and expand the JSP Errors node. Figure 4-10 shows how the error in the code is shown in the Structure window.

    Figure 4-10 Viewing Errors in the Structure Window

    Description of Figure 4-10 follows
    Description of "Figure 4-10 Viewing Errors in the Structure Window"
  5. You must import the ResultSet package. To do this, click the page node in the Structure window to display the page properties in the Property Inspector on the left side of the main editing area.
  6. Right-click inside the empty box to the right of the import property and click Edit. The Edit Property: Import dialog box is displayed, which is shown in Figure 4-11.

    Figure 4-11 Importing Packages in JDeveloper

    Description of Figure 4-11 follows
    Description of "Figure 4-11 Importing Packages in JDeveloper"
  7. Select the Hierarchy tab, expand the java node, then the sql node, and then select ResultSet. Click OK.
  8. On the Source tab, examine the code to see if the import statement has been added to the code for your page. The error should disappear from the list in the Structure window. Before continuing with the following sections, return to the design view of the page by selecting the Design tab.