Adding Filter Controls to the JSP Page

To accept the filter criterion and to display the filter results, you must modify the employees.jsp page. In the following steps, you add a form element and controls to the employees.jsp page that accepts input from users to filter employees by name:

  1. With the employees.jsp page displayed in the Visual Editor, position the cursor between the useBean tag and the scriptlet.
  2. In the HTML Forms page of the Component Palette, select Form.
  3. In the Insert Form dialog box, use the down arrow for the Action field and select employees.jsp. Leave the other fields empty and click OK.

    The form is displayed on the page in the Visual Editor, represented by a dotted-line rectangle.

  4. In the HTML Forms page of the Component Palette, scroll to Text Field. Select it and drag and drop it inside the Form component. In the Insert Text Field dialog, enter query as the value of the Name field and click OK. The text field box is displayed within the form. This field enables users to enter filter criteria.
  5. Position the cursor to the left of the Text Field and add the following text:

    Filter by Employee Name:

  6. In the HTML Forms page of the Component Palette, scroll to Submit Button. Select it and drop it inside the Form component to the right of the Text Field.
  7. In the Insert Submit Button dialog box, leave the Name field empty and enter Filter as the value of the Value field, and click OK.

    Figure 4-14 shows these HTML Form components in the employees.jsp file.

    Figure 4-14 HTML Form Components in the JSP Page

    Description of Figure 4-14 follows
    Description of "Figure 4-14 HTML Form Components in the JSP Page"