L ISTING 19.5
<%@ taglib uri=”/djs” prefix=”djs” %>
Now open your browser to the following URL:
You should see an image similar to Figure 19.3.
F IGURE 19.3
The HelloBody Tag Page.
Tags with Attributes
The last tag you will develop is a tag with attributes. With JSP custom tags you have the ability
to pass attributes to custom tags. You do this by adding an attribute list to the tag element. An
example of this, using a modification of the original hello tag, is in the following code snip-
The preceding snippet has only one attribute: name . When the JSP container encounters this tag
it then checks its matching tag handler for a class-level attribute name . It uses introspection to
find this attribute and then calls its set XXX () method. All tags must have a matching set
method for each attribute that can be included in the tag element's attribute list. The matching
method for the above snippet would be the setName() method. To further examine how this
works, let's develop a tag with attributes.