JSP Tutorials - Herong's Tutorial Examples - v5.11, by Herong Yang
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
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