1 25 26 27 package jsp2.examples.simpletag; 28 29 import javax.servlet.jsp.JspException ; 30 import javax.servlet.jsp.JspWriter ; 31 import javax.servlet.jsp.tagext.SimpleTagSupport ; 32 import javax.servlet.jsp.tagext.DynamicAttributes ; 33 import java.util.ArrayList ; 34 import java.util.Iterator ; 35 import java.io.IOException ; 36 37 40 public class EchoAttributesTag 41 extends SimpleTagSupport 42 implements DynamicAttributes 43 { 44 private ArrayList keys = new ArrayList (); 45 private ArrayList values = new ArrayList (); 46 47 public void doTag() throws JspException , IOException { 48 JspWriter out = getJspContext().getOut(); 49 for( int i = 0; i < keys.size(); i++ ) { 50 String key = (String )keys.get( i ); 51 Object value = values.get( i ); 52 out.println( "<li>" + key + " = " + value + "</li>" ); 53 } 54 } 55 56 public void setDynamicAttribute( String uri, String localName, 57 Object value ) 58 throws JspException 59 { 60 keys.add( localName ); 61 values.add( value ); 62 } 63 } 64 | Popular Tags |