//returns null if no session already exists for the current client
HttpSession session = request.getSession(false);
// creates a new session if no session already exists
// HttpSession session = request.getSession();
if (session == null) {
printMessageSayingCartIsEmpty();
} else {
extractCartAndPrintContents(session);
}
SomeClass value =
(SomeClass)session.getAttribute("someIdentifier");
if (value == null) { // No such object already in session
value = new SomeClass(...);
session.setAttribute("someIdentifier", value);
}
removeAttribute(String name)
Comments
Post a Comment