Wednesday, August 12, 2009

How to create Session object and use it for storing information ?

This code will get the Session context for the current user and place values of count1 and count2 into MyIdentifier1 and MyIdentifier2 respectively

HttpSession session = req.getSession(true); //Creating a Session instance

session.putValue ("MyIdentifier1",count1); // Storing Value into session Object
session.putValue ("MyIdentifier2", count2);

session.getValue(MyIdentifier1); // Prints value of Count

session.removeValue(MyIdentifier1); // Removing Valuefrom Session Object

No comments:

Post a Comment