// Get all session-scoped attributes
HttpSession session = req.getSession();
if (session != null) {
Enumeration enum = session.getAttributeNames();
for (; enum.hasMoreElements(); ) {
// Get the name of the attribute
String name = (String)enum.nextElement();
// Get the value of the attribute
Object value = session.getAttribute(name);
}
}