package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; import javax.servlet.*; /** The then part of an if tag. *

* Taken from Core Servlets and JavaServer Pages * from Prentice Hall and Sun Microsystems Press, * http://www.coreservlets.com/. * © 2000 Marty Hall; may be freely used or adapted. */ public class IfThenTag extends BodyTagSupport { public int doStartTag() throws JspTagException { IfTag parent = (IfTag)findAncestorWithClass(this, IfTag.class); if (parent == null) { throw new JspTagException("then not inside if"); } else if (!parent.hasCondition()) { String warning = "condition tag must come before then tag"; throw new JspTagException(warning); } if (parent.getCondition()) { System.out.println("Testing THEN "); return(EVAL_BODY_INCLUDE); } else { return(SKIP_BODY); } } }