You are on page 1of 1

RequestDispatcher:-

 It is an interface present in javax.servlet.http package.


 It is used to dispatch a request from one resource to another resource.
 Resource may be html, servlet and JSP.
 HttpSevletRequest provides a method getRequestDispatcher( ) to get reference of
RequestDispatcher.
 This method takes the url pattern of the next resource.
 RequestDispatcher has two method:

*public void forward(request, response)


*public void include(request, response)

 HttpServletRequest provides 2 method:

*public void setAttribute(String key, object value)


*public object getAttribute(String key)

HttpSession:-
 It is an interface present in javax.servlet.http package.
 It is used to identify a user.
 By using session we can get the user login time or creation time and used for
invalidating the session.
 HttpServletRequest provide method getSession( ) to get the reference of
HttpSession.

Syntax:
HttpSession ses = request.getSession();
&
HttpSession ses = request.getSession(boolean b);

Methods of HttpSession:-
*public void setAttribute(String key, object value)
*public object getAttribute(String key)
*public void invalidate()

You might also like