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 MessageTag extends BodyTagSupport { 51 52 55 private String type = "text"; 56 57 60 private String charset = null; 61 62 73 public int doAfterBody() throws JspException { 74 75 MailTag myparent = (MailTag)findAncestorWithClass(this, MailTag.class); 77 if (myparent == null) { 78 throw new JspException ("message tag not nested within mail tag"); 79 } 80 81 BodyContent body = getBodyContent(); 82 String message = body.getString(); 83 body.clearBody(); 85 if (message == null) { 86 throw new JspException ("The message tag is empty"); 87 } 88 myparent.setMessage(message); myparent.setType(type); myparent.setCharset(charset); return SKIP_BODY; 92 } 93 94 100 public void setType(String value) { 101 type = value; 102 } 103 104 110 public void setCharset(String value) { 111 charset = value; 112 } 113 } 114 | Popular Tags |