Java Reference
In-Depth Information
The required JSP will allow us to make use of a 'body' within the <jsp:useBean>
tag for holding the <jsp:setProperty> tag and setting the bean properties to the
form values. When a body is used, an explicit < / jsp:useBean> closing tag is
required. Assuming that our bean instance is to be called purchase , the opening
lines of our JSP will be as follows:
<jsp:useBean id="purchase" class="shopping.OrderBean">
<jsp:setProperty name="purchase" property="*" />
</jsp:useBean>
For retrieving and displaying properties, we can again make use of
<jsp:getProperty> tags. To emphasise the setting of property values that has
occurred, the names of bean properties will be displayed in the table output. Here's
the code for the JSPā€¦
<HTML>
<%@ page language="java" contentType="text/html" %>
<jsp:useBean id="purchase" class="shopping.OrderBean">
<jsp:setProperty name="purchase" property="*" />
</jsp:useBean>
<HEAD>
<TITLE>Order Bean Test</TITLE>
<STYLE>
body {text-align:center;}
</STYLE>
</HEAD>
<BODY>
<H1>Results</H1>
<BR>
<TABLE STYLE="background-color:aqua">
<TR>
<TH STYLE="background-color:orange">
Field Name</TH>
<TH STYLE="background-color:orange">
Value</TH>
</TR>
<TR>
<TD>name</TD>
<TD><jsp:getProperty name="purchase"
property="name" /></TD>
</TR>
<TR>
<TD>addressLine1</TD>
<TD><jsp:getProperty name="purchase"
Search WWH ::




Custom Search