Open a session in a JEE Servlet (to do each time, in all Servlets that you want to access to Session variables)
// GET the current session from the request
HttpSession session = request.getSession();
In a JEE Servlet or JSP with <% %> tags, *** Session must be opened before! ***
// ADD a variable (User in this case) to a session
session.setAttribute("user", user);
In a JEE Servlet or JSP with <% %> tags, , *** Session must be opened before! ***
// GET a variable (User in this case) from the session
User user = (User) session.getAttribute("user");
In a JEE Servlet or JSP with <% %> tags, , *** Session must be opened before! ***
// Delete a variable (User in this case) from the session
session.removeAttribute("user");
In a JEE Servlet or JSP with <% %> tags, , *** Session must be opened before! ***
// To destroy the current session
session.invalidate();
Enjoy !