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