14.2. Defining a Basic Tag

This section gives details on defining simple tags without attributes or tag bodies; the tags are thus of the form <prefix:tagname />.

The Tag Handler Class

Tags that either have no body or that merely include the body verbatim should extend the TagSupport class. This is a built-in class in the javax.servlet.jsp.tagext package that implements the Tag interface and contains much of the standard functionality basic tags need. Because of other classes you will use, your tag should normally import classes in the javax.servlet.jsp and java.io packages as well. So, most tag implementations contain the following import statements after the package declaration:

 import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; ...

Get Core Servlets and JavaServer Pages™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.