what is use of session tracking ?with example?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is finalize method?

587


What about main thread in java?

658


What do you mean by flow of struts?

755


Can two objects have same hashcode?

571


What is the relationship between class and object?

533






What is a control variable example?

540


What are user defined exceptions?

598


How many bytes is a unicode character?

520


What do you mean by buffering?

563


Why do we need autoboxing in java?

530


How to create a thread in java?

617


What is r in java?

604


What is a dot notation?

560


What is difference between path and classpath?

571


what is the difference between future and callable interface in java?

614