Persistent Cookies Stored on Hard Disk
This section describes what are persistent cookies - cookies that are stored in files on hard disk. Persistent cookies will be sent back to the server when open the browser again later.
There are two kinds of cookies: persistent cookies and temporary cookies.
A persistent cookie is a cookie stored as a file on your computer, and it remains
there when you close Internet Explorer. The cookie can be read by the Web site
that created it when you visit that site again. You can use cookie.setMaxAge(s)
to set the cookie to be persistent for 's' seconds.
A temporary or session cookie is stored only for your current browsing session,
and is deleted from your computer when you close Internet Explorer. You can
use cookie.setMaxAge(-1) to set the cookie to be temporary.
Other properties of a cookie object that you can set and get:
- setPath(): Defines the path name so that when a pages under this path name is requested,
the browser will send this cookie to the server. The path name is the URL without the server
name and the port number parts.
- setDomain(): Defines the domain name so that when a page under this domain name
is requested, the browser will send this cookie to the server. The default domain name is
the server name from which the cookie was created.
- setMaxAge(): Defines how long the cookie should be stored on the browser's machine.
MaxAge value is in unit of second. A negative value tells the browser to not save it to the
hard disk. A zero value tells the browser to delete it.
- setVersion(): Defines the version number to which this cookie is compliant with.
Last update: 2012.
Table of Contents
About This Book
JSP (JavaServer Pages) Overview
Tomcat 7 Installation on Windows Systems
JSP Scripting Elements
Java Servlet Introduction
JSP Implicit Objects
Syntax of JSP Pages and JSP Documents
JSP Application Session
►Managing Cookies in JSP Pages
What Is a Cookie?
Sending and Receiving Cookies in JSP Pages
►Persistent Cookies Stored on Hard Disk
Persistent Cookie Test Example
Dumping HTTP Response with Cookies
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Performance of JSP Pages
EL (Expression Language)
Overview of JSTL (JSP Standard Tag Libraries)
JSTL Core Library
JSP Custom Tags
JSP Java Tag Interface
Custom Tag Attributes
Multiple Tags Working Together
File Upload Test Application
PDF Printing Version