Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
8.3 The Servlet Cookie API
185
public String getPath()
public void setPath(String path)
These methods get or set the path to which the cookie applies. If you don't 
specify a path, the browser returns the cookie only to URLs in or below 
the directory containing the page that sent the cookie. For example, if 
the server sent the cookie from 
http://ecommerce.site.com/toys/ 
specials.html
, the browser would send the cookie back when connect 
ing to 
http://ecommerce.site.com/toys/bikes/beginners.html
, 
but not to 
http://ecommerce.site.com/cds/classical.html
. The 
setPath
 method can be used to specify something more general. For 
example, 
someCookie.setPath("/")
 specifies that all pages on the
server should receive the cookie. The path specified must include the 
current page; that is, you may specify a more general path than the 
default, but not a more specific one. So, for example, a servlet at 
http://host/store/cust service/request
 could specify a path of 
/store/
 (since 
/store/
 includes 
/store/cust service/
) but not a 
path of 
/store/cust service/returns/
 (since this directory does not 
include 
/store/cust service/
).
public boolean getSecure()
public void setSecure(boolean secureFlag)
This pair of methods gets or sets the boolean value indicating whether 
the cookie should only be sent over encrypted (i.e., SSL) connections. 
The default is 
false
; the cookie should apply to all connections.
public String getValue()
public void setValue(String cookieValue)
The 
getValue
 method looks up the value associated with the cookie; 
the 
setValue
 method specifies it. Again, the name and the value are 
the two parts of a cookie that you almost always care about, although in 
a few cases, a name is used as a boolean flag and its value is ignored (i.e., 
the existence of a cookie with the designated name is all that matters). 
public int getVersion()
public void setVersion(int version)
These methods get/set the cookie protocol version the cookie complies 
with. Version 0, the default, follows the original Netscape specification 
(http://www.netscape.com/newsref/std/cookie_spec.html
). 
Version 1, not yet widely supported, adheres to RFC 2109 (retrieve 
RFCs from the archive sites listed at 
http://www.rfc editor.org/
).
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved