1 16 17 package org.apache.taglibs.mailer; 18 19 import javax.servlet.jsp.JspException ; 20 import javax.servlet.jsp.tagext.BodyContent ; 21 import javax.servlet.jsp.tagext.BodyTagSupport ; 22 23 49 50 public class HeaderTag extends BodyTagSupport { 51 52 55 String name; 56 59 String value = null; 60 61 72 public int doAfterBody() throws JspException { 73 74 MailTag myparent = (MailTag)findAncestorWithClass(this, MailTag.class); 76 77 if (myparent == null) { 78 throw new JspException ("header tag not nested within mail tag"); 79 } 80 BodyContent body = getBodyContent(); 81 String valueStr = value; 82 if (valueStr == null ) { 83 valueStr = body.getString(); 84 } 85 body.clearBody(); 87 if (valueStr == null) { 88 throw new JspException ("The header tag is empty"); 89 } 90 myparent.setHeader(name,valueStr); return SKIP_BODY; 92 } 93 94 100 public void setName(String value) { 101 name = value; 102 } 103 104 110 public void setValue(String value) { 111 this.value = value; 112 } 113 } 114 | Popular Tags |