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="" 
   xmlns:hy="urn:jsptld:/WEB-INF/tlds/HyTaglib.tld" version="2.1"> 
<!-- TraceTagTest.jspx
 - Copyright (c) 2012,, All Rights Reserved.
< contentType="text/html"/>
<hy:trace myAtt="my value">
<jsp:text>JSP body</jsp:text><br/>

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.

Last update: 2012.

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 -

IterationTag Interface Test JSP - TraceTagTest.jspx

 Servlet Class Converted from JSP -

 TagSupport Class - Dummy Implementation of IterationTag

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Outdated Tutorials


 PDF Printing Version