Lesson 7: Add elements to JSPs
Use this lesson to learn how to add input fields, push buttons, and output fields to JSP pages to create dynamic user interfaces for input and output.
In the input fields, the user of the resulting application will type the day, month, and year of interest. The input page includes Submit and Refresh buttons. In the output field, the corresponding day of the week will be displayed. To create these pages:
Input page
To add fields and push buttons to the input JSP page:
- In your Web diagram, double-click the input.jsp page to open the page in the editor.
- In the editor, click the Design tab.
- In the main menu bar, select
Window | Show View | Other.
- In the window, select
Web | Page Data and click OK to open the Page Data view.
- In the Page Data view, expand the
Struts Form Beans folder. Find the dateData form bean and the fields that you defined.
- Drag
dateData from the Page Data view onto the input JSP page in the editor. The
Insert Data Object dialog opens.
- Clear dayofWeek
- Select
Updating an existing record.
- Click
Options, and ensure that the
Submit button and
Delete button check boxes are selected. Then click OK.
- Click Finish to create the fields and buttons in the form.
- Save and close the input JSP file.
Output page
To add fields to the output JSP page:
- In your Web diagram, double-click the output.jsp page to open the page in the editor.
- In the editor, click the Design tab.
- In the Page Data view, expand the
Struts Form Beans folder. Drag
dateData from the Page Data view onto the input JSP page in the editor. The
Insert Data Object dialog opens.
- Clear
year,
month, and
day
- Select
Displaying an existing record and click Finish to create the fields in the page.
- Save and close the output JSP file.
Lesson checkpoint
In this lesson, you added input fields and push buttons to the input JSP page. You also added output fields to the output JSP page.
You learned to do these tasks:
- Open and modify a JSP page.
- Add input fields, output fields, and buttons to a JSP page.