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 72 73 74 public class EqualsCookieTag extends TagSupport 75 { 76 private String name = null; 77 private String match = null; 78 private boolean ignoreCase = false; 81 private boolean value = true; 82 83 90 public final int doStartTag() throws JspException 91 { 92 boolean result = false; 94 Cookie cookie = null; 96 Cookie [] cookies = 97 ((HttpServletRequest)pageContext.getRequest()).getCookies(); 98 if( cookies != null ) { 99 for( int i = 0; i < cookies.length; i++ ) { 100 if( cookies[i].getName().equals(name) ) { 101 cookie = cookies[i]; 102 break; 103 } 104 } 105 } 106 107 if (cookie != null) { 108 if (ignoreCase) { 109 result = cookie.getValue().equalsIgnoreCase(match); 110 } else { 111 result = cookie.getValue().equals(match); 112 } 113 } 114 115 if( value == result ) 116 return EVAL_BODY_INCLUDE; 117 118 return SKIP_BODY; 119 } 120 121 126 public final void setName(String str) 127 { 128 name = str; 129 } 130 131 132 138 public final void setMatch(String str) { 139 match=str; 140 } 141 142 143 151 public final void setIgnoreCase(boolean value) { 152 ignoreCase = value; 153 } 154 155 160 public final void setValue(boolean value) 161 { 162 this.value = value; 163 } 164 165 } 166 | Popular Tags |