Setting and removing session - Jsp

Session

Snippet Code


  
Rate this page :
  [ 0 votes]

By using this code we can set session in servlet. For JSP page there is no need to initialize session object

Setting session HttpSession session = req.getSession(true); session.setAttribute("user",5); Removing session HttpSession session = req.getSession(true); session.removeAttribute("user");//removing session variable session.invalidate();

Tags


Ask Questions

Ask Question