1 16 17 package org.apache.taglibs.request; 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 53 54 public class ParameterValuesTag extends BodyTagSupport 55 { 56 private String [] values = null; 57 private String value = null; 58 private int parameter_num = 0; 59 60 65 public final int doStartTag() throws JspException 66 { 67 values = null; 69 value = null; 70 parameter_num = 0; 71 72 ParametersTag pt; 74 try { 75 pt = (ParametersTag)this.findAncestorWithClass(this, 76 Class.forName("org.apache.taglibs.request.ParametersTag")); 77 } catch(Exception e) { 78 return SKIP_BODY; 79 } 80 81 values = ((HttpServletRequest)pageContext.getRequest()).getParameterValues(pt.getName()); 83 if( values == null || values.length == 0 ) 84 return SKIP_BODY; 85 86 value = values[0]; 87 if( value == null ) 88 return SKIP_BODY; 89 90 pageContext.setAttribute(id,this,PageContext.PAGE_SCOPE); 91 return EVAL_BODY_TAG; 92 } 93 94 99 public final int doAfterBody() throws JspException 100 { 101 parameter_num++; 102 if( parameter_num >= values.length ) 104 return SKIP_BODY; 105 value = values[parameter_num]; 107 if( value == null ) 108 return SKIP_BODY; 109 return EVAL_BODY_TAG; 110 } 111 112 116 public final int doEndTag() throws JspException 117 { 118 pageContext.removeAttribute(id,PageContext.PAGE_SCOPE); 119 try 120 { 121 if(bodyContent != null) 122 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 123 } catch(java.io.IOException e) 124 { 125 throw new JspException("IO Error: " + e.getMessage()); 126 } 127 return EVAL_PAGE; 128 } 129 130 137 public final String getValue() 138 { 139 return value; 140 } 141 142 } 143 | Popular Tags |