Professional Documents
Culture Documents
Forwards arequest from aservlet to another resource (servlet, JSP file, or HTML fle) on the servery
response)throws
public void include(ServletRequest request,ServletResponse
ServletExXception, java.io.IOException:
Includes the content of a resource (servlet, JSP page, or HTML file) in the response/
67
RequestDispatcher
Unit lI-Chapter 1
tareardmhed
incudellmethed
Seretl
Sen
getet
Fint
Some of the common usage of cookies are:
) Request
2) Response + Cookie
Browser
Server
L4 Serviet Cookies Methods
public void setDomain(String pattern)
This method sets the domain to which cookie applies, for example google.com.
public String getDomain()
" This method gets the domain to which cookie applies, for example google.com.
public void setMaxAge(int expiry)
expires.
This method sets how much time (in seconds) should elapse before the cookie
74
Cookies
Unit ll- Chapter 2
|1. Introduction
Kession simply means a particular interval of time.
Session Tracking is a way to maintain state (data) of an user, It is also known as session
management in servlet
.Attp protocol is a stateless so we need to maintain state using session tracking
techniques. Each time user requests the server, server treats the request as the new
request. So we need to maintain e state of an user to recognize to particular user.
HTTP 0s stateless that means each request is considered as the new request.
All requests and responses are independent. But sometimes you need to keep track of
client's activity across multiple requests( For eg. When a User logs into your website,
not matter on which web page he visits after logging in, his credentials will bewith the
server, until he logs out. So this is managed by creating asession.
" Session is used to store everything that we can get from the cli¿nt from all the requests
the client makes.
3.5 Session Management API
of the
Session Management API is built on top of above methods for session tracking. Some
major disadvantages of all the above methods are:
we have to store some data
1/ Most of the time we don't want to only track the session, requirea lot of effort if we
we can use in future requests. .This will
into the session that
try to implement this. complete in themselves, all of them won't work in a
2. All the above methods are not methods of session
solution that can utilize these
particular scenario. So we need a
cases
tracking to provide session management in all
bie trom the original ðo package.