1 16 17 package org.apache.taglibs.response; 18 19 import java.util.*; 20 import javax.servlet.*; 21 import javax.servlet.http.*; 22 import javax.servlet.jsp.*; 23 import javax.servlet.jsp.tagext.*; 24 25 45 46 public class AddIntHeaderTag extends BodyTagSupport 47 { 48 private String name = null; 49 50 55 public final int doStartTag() throws JspException 56 { 57 return EVAL_BODY_TAG; 58 } 59 60 65 public final int doAfterBody() throws JspException 66 { 67 BodyContent body = getBodyContent(); 69 String s = body.getString().trim(); 70 body.clearBody(); 73 74 int value = 0; 75 try { 76 value = Integer.valueOf(s).intValue(); 77 } catch(NumberFormatException e) { 78 throw new JspException("Response tag addIntHeader: " + 79 e.getMessage()); 80 } 81 82 ((HttpServletResponse)pageContext.getResponse()).addIntHeader(name,value); 83 return SKIP_BODY; 84 } 85 86 91 public final void setName(String nam) 92 { 93 name = nam; 94 } 95 96 } 97 | Popular Tags |