001 package railo.runtime.tag; 002 003 import railo.runtime.exp.PageException; 004 import railo.runtime.ext.tag.TagImpl; 005 import railo.runtime.type.KeyImpl; 006 007 /** 008 * Defines cookie variables, including expiration and security options. 009 * 010 * 011 * 012 **/ 013 public final class Cookie extends TagImpl { 014 015 /** Yes or No. Specifies that the variable must transmit securely. If the browser does not support 016 ** Secure Socket Layer (SSL) security, the cookie is not sent. */ 017 private boolean secure=false; 018 019 /** The value assigned to the cookie variable. */ 020 private String value=""; 021 022 /** */ 023 private String domain=null; 024 025 /** */ 026 private String path="/"; 027 028 /** Schedules the expiration of a cookie variable. Can be specified as a date (as in, 10/09/97), 029 ** number of days (as in, 10, 100), "Now", or "Never". Using Now effectively deletes the cookie from 030 ** the client browser. */ 031 private Object expires="-1"; 032 033 /** The name of the cookie variable. */ 034 private String name; 035 036 037 /** 038 * @see javax.servlet.jsp.tagext.Tag#release() 039 */ 040 public void release() { 041 super.release(); 042 secure=false; 043 value=""; 044 domain=null; 045 path="/"; 046 expires="-1"; 047 name=null; 048 } 049 050 /** set the value secure 051 * Yes or No. Specifies that the variable must transmit securely. If the browser does not support 052 * Secure Socket Layer (SSL) security, the cookie is not sent. 053 * @param secure value to set 054 **/ 055 public void setSecure(boolean secure) { 056 this.secure=secure; 057 } 058 059 /** set the value value 060 * The value assigned to the cookie variable. 061 * @param value value to set 062 **/ 063 public void setValue(String value) { 064 this.value=value; 065 } 066 067 /** set the value domain 068 * 069 * @param domain value to set 070 **/ 071 public void setDomain(String domain) { 072 this.domain=domain; 073 } 074 075 /** set the value path 076 * 077 * @param path value to set 078 **/ 079 public void setPath(String path) { 080 this.path=path; 081 } 082 083 /** set the value expires 084 * Schedules the expiration of a cookie variable. Can be specified as a date (as in, 10/09/97), 085 * number of days (as in, 10, 100), "Now", or "Never". Using Now effectively deletes the cookie from 086 * the client browser. 087 * @param expires value to set 088 **/ 089 public void setExpires(Object expires) { 090 this.expires=expires; 091 } 092 093 /** set the value expires 094 * Schedules the expiration of a cookie variable. Can be specified as a date (as in, 10/09/97), 095 * number of days (as in, 10, 100), "Now", or "Never". Using Now effectively deletes the cookie from 096 * the client browser. 097 * @param expires value to set 098 * @deprecated replaced with setExpires(Object expires):void 099 **/ 100 public void setExpires(String expires) { 101 this.expires=expires; 102 } 103 104 /** set the value name 105 * The name of the cookie variable. 106 * @param name value to set 107 **/ 108 public void setName(String name) { 109 this.name=name; 110 } 111 112 113 /** 114 * @see javax.servlet.jsp.tagext.Tag#doStartTag() 115 */ 116 public int doStartTag() throws PageException { 117 pageContext.cookieScope().setCookie(KeyImpl.getInstance(name),value,expires,secure,path,domain); 118 return SKIP_BODY; 119 } 120 121 /** 122 * @see javax.servlet.jsp.tagext.Tag#doEndTag() 123 */ 124 public int doEndTag() { 125 return EVAL_PAGE; 126 } 127 }