1 16 package examples; 17 18 import javax.servlet.jsp.*; 19 import javax.servlet.jsp.tagext.*; 20 import java.util.Hashtable ; 21 import java.io.Writer ; 22 import java.io.IOException ; 23 24 30 31 public class FooTag 32 extends ExampleTagBase 33 { 34 private String atts[] = new String [3]; 35 int i = 0; 36 37 private final void setAtt(int index, String value) { 38 atts[index] = value; 39 } 40 41 public void setAtt1(String value) { 42 setAtt(0, value); 43 } 44 45 public void setAtt2(String value) { 46 setAtt(1, value); 47 } 48 49 public void setAtt3(String value) { 50 setAtt(2, value); 51 } 52 53 58 public int doStartTag() throws JspException { 59 i = 0; 60 return EVAL_BODY_TAG; 61 } 62 63 public void doInitBody() throws JspException { 64 pageContext.setAttribute("member", atts[i]); 65 i++; 66 } 67 68 public int doAfterBody() throws JspException { 69 try { 70 if (i == 3) { 71 bodyOut.writeOut(bodyOut.getEnclosingWriter()); 72 return SKIP_BODY; 73 } else 74 pageContext.setAttribute("member", atts[i]); 75 i++; 76 return EVAL_BODY_TAG; 77 } catch (IOException ex) { 78 throw new JspTagException(ex.toString()); 79 } 80 } 81 } 82 83 | Popular Tags |