O'Reilly logo

Sams Teach Yourself J2EE™ in 21 Days by Peter Roxburgh, Andy Longshaw, Debbie Law, Dan Haywood, Martin Bond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Processing Tag Bodies

So far, you have seen tags that treat the text in the body of the tag as simple JSP (or HTML) data. But tags can also manipulate the tag body in any way they choose. A simple example would be a tag that interprets its body as an SQL statement and uses this to query the database. Listing 14.18 shows a simple use of such a tag.

Listing 14.18. Full Text of select.jsp
 1: <%@ taglib uri="/demo" prefix="demo" %>
 2: <HTML>
 3: <HEAD>
 4: <TITLE> Tag Library SQL Query Demo</TITLE>
 5: <BODY>
 6:   <demo:select>
 7:     SELECT * FROM Customer
 8:   </demo:select>
 9: </BODY>
10: </HTML>
					

The implementation of this select tag must state in the TLD that the body text is tag dependent, as shown in the following:

 <tag> <name>select</name> <tag-class>demo.SelectTag</tag-class> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required