by
[Help |
API Docs |
Short Course|
Exercises]
In this exercise, you develop a simple JSP page (form.jsp), which can process an HTML form containing typical input elements like textboxes, radio buttons, and checkboxes. You also develop a bean (FormBean.java), whose property names mirror the input elements of the form. You will then examine the automatic instantiation of the bean on a form POST operation, using the introspective features provided by the JSP engine.
Prerequisites
Skeleton Code
Tasks
1. You are given the JSP page containing the form. Observe that the form posts to itself
recursively. Instantiate the bean FormBean when you recognize that a POST
operation has taken place. Allow the setter methods to be called on the bean using
introspection.
2. Deploy the JSP page within Tomcat.
3. Develop the bean, FormBean.java, with properties matching the form elements.
4. Compile the bean source FormBean.java.
5. Deploy the bean within Tomcat.
6. Run the example.
Where help exists, the task numbers above are linked to the
step-by-step help page.
Solution Source
Demonstration
From your browser, access the URL http://localhost:8080/examples/jsp/jdc/forms/form.jsp.
You should see an HTML form as shown below:
Fill in data for all the form input elements, before performing a submit:
On submission, you should see the data you entered extracted from the bean and displayed beneath the form:
Copyright 1996-2000 jGuru.com. All Rights Reserved.
|