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) 2012, 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

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 7 Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

 Managing Cookies in JSP Pages

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

 Overview of JSTL (JSP Standard Tag Libraries)

 JSTL Core Library

 JSP Custom Tags

JSP Java Tag Interface

 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

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Outdated Tutorials

 References

 PDF Printing Version