Master java skills

session Implicit Object

session is an implicit object of HttpSession class. This object can be used to get/store session information.

session Object Example

index.html

<html>  
  <body>  
    <form action="welcome.jsp">  
      Username : <input type="text" name="username">  
      <input type="submit" value="Submit"><br/>  
    </form>  
  </body>  
</html> 

welcome.jsp

<html>  
  <body>  
    <%   
      String username = request.getParameter("username");  
      out.print("Welcome " + username + "<br>");  
      session.setAttribute("user", username);  
      <a href="introduction.jsp">Introduction jsp page</a>  
    %>  
  </body>  
</html>  

introduction.jsp

<html>  
  <body>  
    <%   
      String user = (String)session.getAttribute("user");  
      out.print("The value of user from the session : " + user);  
    %>  
  </body>  
</html>  

Run and test