How would you keep track of a session

Showing Answers 1 - 6 of 6 Answers

Pankaj Dwivedi

  • Jun 16th, 2005
 

Session tracking is a mechanism that servlets use to maintain state about a series of requests from the same user (that is, requests originating from the same browser) across some period of time.  
 
Sessions are shared among the servlets accessed by a client. This is convenient for applications made up of multiple servlets. For example, Duke's Bookstore uses session tracking to keep track of the books being ordered by a user. All the servlets in the example have access to the user's session.  
 
To use session tracking,  
 
 
Get a session (an HttpSession object) for a user.  
 
Store or get data from the HttpSession object.  
 
Invalidate the session (optional

  Was this answer useful?  Yes

ramesh

  • Sep 9th, 2005
 

In servlets, session can be tracked using  
a) URL rewriting 
b) Hiddin FormField 
c) cookies 
and  
d) HttpSession API 
 
In EJB to maintain session go for stateful session beans.

vijaysdange

  • Mar 25th, 2006
 

 use session varaible accross application

             String vijay=request.getParameter("vijay");

         HttpSession createobject name as hs

          HttpSesssion hs=request.getSession("true");

              this create session object

         then call

           object.setAttribute("value which we will retrive later",value);

         means

              hs.setAttribute("sessionobject",vijay);

   now on second form

we call as

         String name=(String)request.getAttribute("sessionobject");

           out.println("name");

 in this way we can maintain session with diffrent

  isNew() check wether session is new

 while invalidating use session.invalidate()

  Was this answer useful?  Yes

Rushi

  • Apr 21st, 2009
 

HTTP is a stateless protocol so, for maitaining the session there are three session tracking technices
1. Cookies
2. URL rewriting
3. Hidden Form fields

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions