What Are Cookies
What Are Cookies
Public intgetMaxAge()
It returns the maximum age of cookie
Public String getName()
It returns the name of the cookie
Action_cookie_main.jsp
Session Tracking :
HTTP is a "stateless" protocol which means each time
a client retrieves a Web page, the client opens a new
connection to the Web server and the server does not
keep any record of previous client request.
Session tracking is a mechanism that is used to
maintain state about a series of requests from the
same user(requests originating from the same
browser) across some period of time.
A session id is a unique token number assigned to a
specific user for the duration of that user's session.
Cookies :
Cookies mostly used for session tracking. Cookie is a key
value pair of information, sent by the server to the
browser. This should be saved by the browser in its space
in the client computer. Whenever the browser sends a
request to that server it sends the cookie along with it.
Then the server can identify the client using the cookie.
This is not an effective way because many time browser
does not support a cookie or users can opt to disable
cookies using their browser preferences. In such case, the
browser will not save the cookie at client computer and
session tracking fails.
URL Rewriting :
Here is a simple URL which will pass two values using
GET method.You can append some extra data on the end
of each URL that identifies the session, and the server can
associate that session identifier with data it has stored
about that session.For Example Original
URL:http://javwebtutor.com/jsp/name Rewritten
URL: http://javawebtutor.com/jsp/name?sessionid=12345 .
When a request is made an additional parameter is
appended with the url.sessionid=12345, the session
identifier is attached as sessionid=12345 which can be
accessed at the web server to identify the client.
Output in Browser :