March 2008
Intermediate to advanced
911 pages
20h 31m
English
For the simplest of Simple tags, the process is...simple.
Write a class that extends SimpleTagSupport
package foo; import javax.servlet.jsp.tagext.SimpleTagSupport; // more imports needed public class SimpleTagTest1 extends SimpleTagSupport { // tag handler code here }
Override the doTag() method

Create a TLD for the tag
<taglib ...> <tlib-version>1.2</tlib-version> <uri>simpleTags</uri> <tag> <description>worst use of a custom tag</description> <name>simple1</name> <tag-class>foo.SimpleTagTest1</tag-class> <body-content>empty</body-content> </tag> </taglib>
Deploy the tag handler and TLD
Put the TLD in WEB-INF, and put the tag handler inside WEB-INF/classes, using the package directory structure, of course. In other words, tag handler classes go in the same place all other web app Java classes go.

Write a JSP that uses the tag
<%@ taglib prefix="myTags" uri="simpleTags" %> <html><body> <myTags:simple1/> </body></html>
Read now
Unlock full access