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

How do you change an int to a string?

0 Answers  


What is a numeric literal?

0 Answers  


What is the largest data type in java?

0 Answers  


What is JVM ?

4 Answers   Phantom Technologies, TCS,


What are the types of inner classes (non-static nested class) used in java?

0 Answers  






What are the OOPS concepts in Java ?

4 Answers   Satyam,


What is variable and its types?

0 Answers  


If two threads call a static method at the same point of time, what will happen?

3 Answers   KPIT,


What is the base class of all exception classes?

0 Answers  


What are access modifiers in Java ?

6 Answers  


What is an infinite loop?

0 Answers  


What is the use of parse function in java?

0 Answers  


Categories