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

Tags with Attributes

Attributes are used to pass information into a custom tag to configure the behavior of the tag. Tag attributes are like XML or HTML attributes and are name/value pairs of data. The values must be quoted with single or double quotes.

A simple example is a tag that looks up a JNDI name passed in as a parameter. Listing 14.4 shows how such a tag could be used.

Listing 14.4. Full Text of lookup.jsp
1: <%@ taglib uri="/demo" prefix="demo" %>
2: <HTML>
3: <HEAD>
4: <TITLE>Tag Library Lookup Demo</TITLE>
5: <BODY>
6:   <demo:lookup name="jdbc/Agency"/>
7: </BODY>
8: </HTML>

The JSP specification allows attributes to have values that can include Java expressions. If the lookup name had been passed in as a request parameter called ...

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