Tag Handler in JSP

Chapter 10 - Building a Custom Tag Library

    Tag Handler in JSP

  • Tag Handler API and Implementation

    There are two types of tag handler:

    • Classic Tag Handlers implement one of three interfaces:

    Tag

    Implement the javax.servlet.jsp.tagext.Tag interface,its creating a custom tag that does not need access to its interface. The API also provides a class TagSupport that implements the Tag interface and provides default empty methods for the methods defined in the interface.

    BodyTag

    Implement the javax.servlet.jsp.tagext.BodyTag interface the custom tag needs to use a body. The API also provides a class BodyTagSupport that implements the BodyTag interface and provides default empty methods for the methods defined in the interface.

    IterationTag

    Implement the javax.servlet.jsp.tagext.IterationTag interface to extend Tag by defining an additional method doAfterBody() that controls the body of the tag.

    • Simple Tag Handlers (SimpleTag interface):

    Implement the javax.servlet.jsp.tagext.SimpleTag interface.its use a simpler invocation protocol. The SimpleTag interface does not extend the javax.servlet.jsp.tagext.

    Tag interface are BodyTag interface. Therefore, instead of supporting the doStartTag() and doEndTag() methods, the SimpleTag interface provides a simple doTag() method.

© 2015 by Learncertification All Rights Reserved. The certification names are the trademarks of their respective owners. Terms & Privacy Policy