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 to split a string in java?

0 Answers  


what is Thread?

6 Answers  


Define max and min heap, also the search time of heap.

0 Answers   GrapeCity,


Is ++ operator thread-safe in java?

0 Answers  


What are the steps involved to create a bean?

0 Answers  


Describe what happens when an object is created in java ?

0 Answers  


Why do I need to declare the type of a variable in java?

0 Answers  


Is array serializable java?

0 Answers  


Difference String and String Buffer

4 Answers  


What is regex used for?

0 Answers  


What are the two ways you can synchronize a block of code?

5 Answers   Ericsson,


what is Inheritense

3 Answers   Tech Mahindra,


Categories