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

jGuru: Help: Form Processing Using JSP

 


[Exercise | API Docs | Short Course| Exercises]

Help is available for each task.

Task 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.

You can use the useBean tag for instantiating the bean. By indicating property="*" within the setProperty tag, you can direct the JSP engine to parse all the incoming values from the HTML form elements that are part of the request object and assign them to their corresponding bean properties.

Task 2

Deploy the JSP page within Tomcat.

Assuming you have installed Tomcat in say, \jakarta-tomcat, copy the JSP file to \jakarta-tomcat\webapps\examples\jsp\jdc\forms\form.jsp

Task 3

Develop the bean, FormBean.java with properties matching the form elements.

Develop a bean with the names of the bean properties matching the names of the form input elements. Note that values for certain form elements like checkbox, need to be mirrored within an indexed property. Define the corresponding getter/setter methods for each property within the bean.

Task 4

Compile the bean source FormBean.java.

You can compile the bean as javac FormBean.java

Task 5

Deploy the bean within Tomcat.

Copy FormBean.class to \jakarta-tomcat\webapps\examples\WEB-INF\classes\com\jguru\FormBean.class

Task 6

Run the example.

From your browser, access the URL http://localhost:8080/examples/jsp/jdc/forms/form.jsp.

Fill in data for the form input elements and hit submit. You should see the data you entered displayed at the bottom of the page.

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