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 55 56 public class ExistsQueryStringTag extends TagSupport 57 { 58 private String name = null; 59 private boolean value = true; 60 61 66 public final int doStartTag() throws JspException 67 { 68 boolean result = false; 69 String query = 70 ((HttpServletRequest)pageContext.getRequest()).getQueryString(); 71 72 if( query != null ) { 73 StringTokenizer st = new StringTokenizer(query,"&"); 74 String prefix = name + "="; 75 while( st.hasMoreTokens() ) { 76 if( st.nextToken().startsWith(prefix) ) { 77 result = true; 78 break; 79 } 80 } 81 } 82 83 if( value == result ) 84 return EVAL_BODY_INCLUDE; 85 86 return SKIP_BODY; 87 } 88 89 94 public final void setName(String str) 95 { 96 name = str; 97 } 98 99 104 public final void setValue(boolean value) 105 { 106 this.value = value; 107 } 108 109 } 110 | Popular Tags |