Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials & Code Camps

jGuru: Form Processing Using JSP

 


[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:

[Demonstrating beans with varying scope]

Fill in data for all the form input elements, before performing a submit:

[Demonstrating beans with varying scope]

On submission, you should see the data you entered extracted from the bean and displayed beneath the form:

[Demonstrating beans with varying scope]

Exercises

Short Course

Copyright 1996-2000 jGuru.com. All Rights Reserved.

Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.