Class 2 |
Intermediate Java 30-IT-397 |
|
Making a Color Bar
-
Let's make a simple application that uses attributes in JSP tags.
-
The colorbar that you see at the top of this document can easlily be generated
this way. We can send the table border and the cell background colors
as attributes.
-
We define one JSP, a tld file, and three tag handlers.
-
ColorBar.jsp The JSP that will generate
the color bar.
-
table.tld The tag library definition file,
tells us where to find the tag handler classes (below).
-
BeginTable.java Writes the <table>
and <tr> tag, and optionally assigns a border.
-
EndTable.java Writes the </tr> and
</table> tags.
-
Row.java Writes the <td> tags, with an
optional color attribute.
-
We also need to add an entry to web.xml as well.
<taglib>
<taglib-uri>/tbl</taglib-uri>
<taglib-location>table.tld</taglib-location>
</taglib>
-
And finally, the result:
Making Use of the Tag Body

Making Use of the Tag Body
Created by: Brandan Jones
December 17, 2001