Java Reference
In-Depth Information
The first method that you override is the doEndTag() method. You implement this method
because you are not concerned with the content of the body. In the doEndTag() method the
first thing you do is get a reference to a JspWriter that references the current stream being
used for client response. You then use the print() method to write the text Hello string to the
response stream.
The next method you override is the release() method. This is where you would release all of
the resources that you have allocated in the tag. For your purposes, because you did not allo-
cate any resources, you will simply call the parent tag's release method. This is just good prac-
tice as you start to get into more complex tag hierarchies.
To see this tag in action you need to first compile the file and move the class
file into the <SERVER_ROOT>/webapps/djs/WEB-INF/classes/com/djs/ directory.
You then need to create a tld that describes your tag library. Listing 19.2 contains the source
for your tag library descriptor.
<?xml version=”1.0” encoding=”ISO-8859-1” ?>
<!DOCTYPE taglib
PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN”
<!-- a tag library descriptor -->
Developing Java Servlets 2
<info>Just Says Hello</info>
You only need to examine two parts in this simple tld . The first is the <uri> entry, which is
/djs for your library. This tells the container that this tag library should be referenced when a
JSP's taglib directive contains the same uri .
Search WWH ::

Custom Search