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 ...
Get Sams Teach Yourself J2EE™ in 21 Days now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.