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

Explain constructors and types of constructors in java.

646


How does singleton class work?

530


What do you understand by the term string pool?

570


What is class variable java?

585


What is methods in java?

516






Which is easier netbeans or eclipse?

614


What is core java called?

526


What is singleton class and how can we make a class singleton?

661


What is string builder?

470


What is a native method in java programming?

529


Why arraylist is not synchronized in java example?

472


What is method overloading with type promotion?

581


What does s mean in regex?

553


What are the two main uses of volatile in Java?

606


What is difference between c++ and java ?

673