Java Reference
In-Depth Information
<table border=1 width=50%>
<tr>
<th>Account</th>
<th>Owner</th>
<th>Value</th>
</tr>
<% // for each subaccount:
for (Iterator actit = acct.getAllSubs(); actit.hasNext(); ) {
Account suba = (Account) actit.next();
%>
<tr>
<td><a href="BPControl?name=<%= suba.getName() %>&func=cd">
<%= suba.getName() %>
</a></td>
<td>albing</td>
<td>
<%= suba.getTotal().toString() %>
</td>
</tr>
<%
} // next acct
%>
</table>
Notice how it starts off as simply the HTML building the table
opening. Then we encounter some Java source code, enclosed in delimiters
( <% ... %> ), then back to plain HTML. There's even a line which intermixes
HTML and Java:
<td><a href="BPControl?name=<%= suba.getName() %>&func=cd">
To understand what's going on here, let's take a look at four pieces of
syntax that are the keys to JSP.
19.3
H OW TO W RITE A JSP A PPLICATION
Writing a JSP application consists, syntax-wise, of writing your desired output
page in HTML and, where you need the dynamic bits, putting Java code and/or
other special syntax inside special delimiters that begin with <% .
There are four special delimiters that we should describe if you're going
to work with JSP. The bulk of your JSP will likely be HTML. But interspersed
among the HTML will be Java source or JSP directives, inside of these four
kinds of delimiters:
Search WWH ::




Custom Search