HttpSession Interface helps in a way to recognise a user across more than one page request. Servlet container uses this interface to create a session between HttpClient and HttpServer.
This Interface helps servlets to
- manipulate and view information about session
- binding information in the form of object with session so that that information can persist across many sites
We can obtain a HttpSession using getSession() of HttpServletRequest as
HttpSession session=request.getSession();
In order to set attribute with this object by using setAttribute() which takes two argument as
session.setAttribute("uname",Test);
In order to retrieve these value associated with session by using HttpSession using getAttribute("uname") as
String n=(String)session.getAttribute("uname");
In this way , We can Implement HttpSeesion In Servlet. Thanks for Reading...
0 Comment(s)