1 package de.jwi.jgallery.tags; 2 3 24 25 26 import java.util.EmptyStackException ; 27 import java.util.Stack ; 28 29 import javax.servlet.ServletRequest ; 30 import javax.servlet.jsp.JspException ; 31 import javax.servlet.jsp.tagext.BodyTagSupport ; 32 33 38 public class ElseTag extends BodyTagSupport 39 { 40 41 private boolean popResult() 42 throws JspException 43 { 44 Boolean b; 45 46 ServletRequest request = pageContext.getRequest(); 47 Stack stack = (Stack ) request.getAttribute("ifThenStack"); 48 if (null != stack) 49 { 50 try 51 { 52 b = (Boolean ) stack.pop(); 53 } 54 catch (EmptyStackException e) 55 { 56 throw new JspException ("EmptyStackException: Else Tag without If"); 57 } 58 } 59 else 60 { 61 throw new JspException ("Else Tag without If"); 62 } 63 return b.booleanValue(); 64 } 65 66 public int doStartTag() throws JspException 67 { 68 boolean lastResult = popResult(); 69 if (lastResult) 70 { 71 return SKIP_BODY; 72 } 73 else 74 { 75 return EVAL_BODY_INCLUDE; 76 } 77 } 78 } 79 | Popular Tags |