what is use of session tracking ?with example?



what is use of session tracking ?with example?..

Answer / sivasubramanian.k

Session Tracking is one of the most powerful features of
Servlets and JSP. Basically, the servlet engine takes care
of using Cookies in the right way to preserve state across
successive requests by the same user. Your servlet just
needs to call a single method (getSession) and it has
access to a persistent hashtable of data that's unique to
the current user

public void doPost(HttpServletRequest request,
HttpServletResponse response){
...
//lets take the session obj
HttpSession session = request.getSession(true);
//now let us take the user name assosiated with this session
String currUserLogin = (String) session.getAttribute
("currentUserLogin")
...
//now we do the work according to the user name
doSomeWork(currUserLogin);
...

}

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Core Java Interview Questions

what is ejb? what is the importance of ejb?

2 Answers   Photon,


how is final different from finally and finalize in java?

0 Answers   DELL,


Can we increase size of array?

0 Answers  


What is flush buffer?

0 Answers  


What is set string?

0 Answers  


What do you mean by platform independence?

0 Answers  


How to convert string to int in java?

1 Answers  


Explain the scope or life time of class variables or static variables?

0 Answers  


how can u apply shallow cloning and deep cloning to create object?

1 Answers   Yash Technologies,


What is JAVA? Why it is platform independent?

10 Answers   NIIT,


How can constructor chaining be done by using the super keyword?

0 Answers  


What are the differences between Java 1.0 and Java 2.0?

0 Answers  


Categories