Cookies
Cookies
Cookies
Working of Cookie
By default, each request is
considered as a new request.
In cookies technique, we add cookie
with response from the servlet. So
cookie is stored in the cache of the
browser.
After that if request is sent by the
user, cookie is added with request by
default. Thus, we recognize the user
as the old user.
Types of Cookie
Non-persistent cookie
It isvalid for single sessiononly. It is
removed each time when user closes
the browser.
Persistent cookie
It isvalid for multiple session. It is
not removed each time when user
closes the browser. It is removed only if
user logout or signout.
Disadvantages:
It will not work if cookie is disabled from
the browser.
Only textual information can be set in
Cookie object.
Cookie class
javax.servlet.http.Cookieclass
provides the functionality of using
cookies. It provides a lot of useful
methods for cookies.
URL Rewriting
In URL rewriting, we append a token or
identifier to the URL of the next Servlet or
the next resource.
We can send parameter name/value pairs
using the following format:
url?name1=value1&name2=value2&??
Advantages and
Disadvantages: