JSP Tutorials - Herong's Tutorial Examples - v5.11, by Herong Yang
TagSupport Class - Dummy Implementation of IterationTag
This section describes the javax.servlet.jsp.tagext.TagSupport class, which is a dummy implementation of the javax.servlet.jsp.tagext.IterationTag interface. Extending from TagSupport class to write your own tag class saves some coding time.
Java EE supplies a dummy implementation class, javax.servlet.jsp.tagext.TagSupport, of the IterationTag interface. If you are designing a new tag class, you may extend your class from TagSupport, instead of implementing IterationTag. Extending your tag class from TagSupport gives you two advantages.
1. No need to code any required method, if you are happy with the default implementation of that method inside TagSupport.
2. TagSupport provides you the pageContext object ready to use. No need for you to code setPageContext() and save it in your tag object.
Here is an example of a tag class that extends the TagSupport class:
/* HelloTag.java * Copyright (c) 2002 HerongYang.com. All Rights Reserved. */ package herong; import java.io.*; import javax.servlet.jsp.tagext.*; public class HelloTag extends TagSupport { public int doStartTag() { try { pageContext.getOut().write("Hello world! - From HelloTag"); } catch (IOException e) { System.err.println(e.toString()); } return SKIP_BODY; } }
Table of Contents
JSP (JavaServer Pages) Overview
Tomcat Installation on Windows Systems
Syntax of JSP Pages and JSP Documents
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Overview of JSTL (JSP Standard Tag Libraries)
javax.servlet.jsp.tagext.* Package
javax.servlet.jsp.tagext.IterationTag Interface
IterationTag Interface Test Class - TraceTag.java
IterationTag Interface Test JSP - TraceTagTest.jspx
Servlet Class Converted from JSP - TraceTagTest_jsp.java
►TagSupport Class - Dummy Implementation of IterationTag
Multiple Tags Working Together
Using Tomcat on CentOS Systems
Connecting to SQL Server from Servlet