JSP Tutorials - Herong's Tutorial Examples - Version 5.00, by Dr. 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) 2012-2018, 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.
Last update: 2018.
Table of Contents