I opened the session in my servlet when the user performed a successful login:
HttpSession session = request.getSession(true);
session.setAttribute(\"name\",
To Validate the Session
HttpSession session = request.getSession(true);
session.setAttribute("name", name);
To invalidate it you need to do
session.removeAttribute("name");
session.invalidate();
But you need to keep one thing in mind that the object may became invalid but this doesnot mean that it will cleaned immediately, even after invalidating it after all its attributes gone it is possible that sesssion object will get reused, I got the same user ID and creation time.