|
Answer» Method 1) By URL rewriting
Method 2) Using SESSION object
Getting Session form HttpServletRequest object
HttpSession session = request.getSession(TRUE);
Get a Value from the session
session.getValue(session.getId());
Adding values to session
cart = new Cart();
session.putValue(session.getId(), cart);
At the end of the session, we can inactivate the session by using the following command
session.invalidate();
Method 3) Using COOKIES
Method 4) Using hidden FIELDS. Method 1) By URL rewriting
Method 2) Using Session object
Getting Session form HttpServletRequest object
HttpSession session = request.getSession(true);
Get a Value from the session
session.getValue(session.getId());
Adding values to session
cart = new Cart();
session.putValue(session.getId(), cart);
At the end of the session, we can inactivate the session by using the following command
session.invalidate();
Method 3) Using cookies
Method 4) Using hidden fields.
|