Java Reference
In-Depth Information
The next section to examine is the <tag> section. It describes the name of the tag and its asso-
ciated tag handler. It also says that the bodycontent for this tag is empty.
The next step is to copy this tld into a directory that can be referenced in the Web applica-
tion's deployment descriptor. For this example, create a directory
<SERVER_ROOT>/webapps/djs/WEB-INF/tlds/ and copy the tld into it.
The final step to deploy your tag library is to add the following section to your application's
web.xml file.
<taglib>
<taglib-uri>/djs</taglib-uri>
<taglib-location>/WEB-INF/tlds/taglib.tld</taglib-location>
</taglib>
Now you can see your new tag in action. Listing 19.3 contains the source for the JSP that will
use your Hello tag.
L ISTING 19.3
Hello.jsp
<%@ taglib uri=”/djs” prefix=”djs” %>
<html>
<body>
<djs:hello /><br>
</body>
</html>
Now open your browser to the following URL:
http://localhost/djs/Hello.jsp
You should see an image similar to Figure 19.2.
F IGURE 19.2
The Hello Tag Page.
Search WWH ::




Custom Search