Java Reference
In-Depth Information
<OPTION value=WI>Wisconsin</OPTION>
<OPTION value=WV>West Virginia</OPTION>
<OPTION value=WY>Wyoming</OPTION>
<OPTION value=YK>Yukon</OPTION>
</SELECT>
</TD>
<TD height=49 vAlign=bottom width=158>
Zip/Postal code<BR><INPUT name=Zip size=15>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD align=center>
<BR/>
<INPUT name=SubmitButton type=SUBMIT value="Click here to
proceed">
<BR/>
<P/>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
After local validation by the JavaScript, the form data is passed to the JSP page
ProcessNAForm.jsp
,
which uses the
ProcessNABean
to insert the form data into the database.
ProcessNAForm.jsp
is a
simple example of a JSP form handler. It loads the
ProcessNABean
and sets its properties using the
wild card property setter that relies on introspection to set all the properties of the JavaBean from the
form data. When the
insertData()
method is called,
ProcessNABean
returns a
boolean
which is
used to set the
String nextPage
to the appropriate handler. Finally, the
<jsp:forward>
tag is
used to forward the user to the appropriate page.
Listing 13-6
shows the JSP page.
Listing 13-6: ProcessNAForm.jsp
<%@ page language="java"%>
<jsp:useBean id="ProcessNABean"
class="JavaDatabaseBible.ch13.ProcessNABean" scope="session"/>
<jsp:setProperty name="ProcessNABean" property="*"/>
<%