Download View - ITtestpapers.com

Transcript
EXAMPLES
The query tag implemented by this tag handler could be used in either of the following ways:
<tt:connection id="con01" ....> ... </tt:connection>
<tt:query id="balances" connection="con01">
SELECT account, balance FROM acct_table
where customer_number = <%= request.getCustno()%>
</tt:query>
<tt:connection ...>
<x:query id="balances">
SELECT account, balance FROM acct_table
where customer_number = <%= request.getCustno()%>
</x:query>
</tt:connection>
The TLD for the tag handler must indicate that the connection attribute is
optional with the following declaration:
<tag>
...
<attribute>
<name>connection</name>
<required>false</required>
</attribute>
</tag>
Examples
The custom tags described in this section demonstrate solutions to two recurring
problems in developing JSP applications: minimizing the amount of Java programming in JSP pages and ensuring a common look and feel across applications. In doing so, they illustrate many of the styles of tags discussed in the first
part of the chapter.
An Iteration Tag
Constructing page content that is dependent on dynamically generated data often
requires the use of flow control scripting statements. By moving the flow control
logic to tag handlers, flow control tags reduce the amount of scripting needed in
JSP pages.
137