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 ExistsCookieTag extends TagSupport 57 { 58 private String name = null; 60 private boolean value = true; 62 63 68 public final int doStartTag() throws JspException 69 { 70 boolean result = false; 71 72 Cookie cookie = null; 74 Cookie [] cookies = 75 ((HttpServletRequest)pageContext.getRequest()).getCookies(); 76 if( cookies != null ) { 77 for( int i = 0; i < cookies.length; i++ ) { 78 if( cookies[i].getName().equals(name) ) { 79 cookie = cookies[i]; 80 break; 81 } 82 } 83 } 84 if( cookie != null ) 85 result = true; 86 87 if( value == result ) 88 return EVAL_BODY_INCLUDE; 89 90 return SKIP_BODY; 91 } 92 93 98 public final void setName(String str) 99 { 100 name = str; 101 } 102 103 108 public final void setValue(boolean value) 109 { 110 this.value = value; 111 } 112 113 } 114 | Popular Tags |