IterationTag Interface Test JSP - TraceTagTest.jspx

This section provides a tutorial example on how to write a JSP page to test the TraceTag class that implements the javax.servlet.jsp.tagext.IterationTag interface.

To test my "hy:trace" tag developed in the previous tutorial, I wrote the following JSP page, TraceTagTest.jspx:

<?xml version="1.0"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
   xmlns:c="http://java.sun.com/jstl/core"
   xmlns:hy="urn:jsptld:/WEB-INF/tlds/HyTaglib.tld" version="2.3">
<!-- TraceTagTest.jspx
 - Copyright (c) 2006 HerongYang.com. All Rights Reserved.
-->
<jsp:directive.page contentType="text/html"/>
<html><body>
<hy:trace myAtt="my value">
<jsp:text>JSP body</jsp:text><br/>
</hy:trace>
</body></html>
</jsp:root>

I put the JSP page on my Tomcat server, and restarted the server. When requesting this JSP page with IE, I got the following output:

setPageContext() called.
setParent() called.
setMyAtt() called.
doStartTag() called.
JSP body
doAfterBody() called.
JSP body
doAfterBody() called.
doEndTag() called.

The output was exactly what I expected. The JSP was indeed evaluated twice as controlled by the returning flag of doAfterBody(). One surprise is that there was no call to release(). I don't know why.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 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

 Using Tomcat on CentOS Systems

 Using Tomcat on macOS Systems

 Connecting to SQL Server from Servlet

 Developing Web Applications with Servlet

 Archived Tutorials

 References

 Full Version in PDF/EPUB