JSP session object
JSP session implicit object is instance of javax.servlet.http.HttpSession.
The instance of HttpSession is created by the web container.
It is used for storing the user’s data to make it available on other JSP pages till the user session is active.if session is inactive then user data is loss.
it is also used to set,get or remove attribute from sessionscope.
Example of session implicit object
index.html
<html>
<body>
<form action="first.jsp">
<input type="text" name="uname">
<input type="text" name="email">
<input type="submit" value="Click"><br>
</form>
</body>
</html>
first.jsp
<html>
<body>
<%
String name=request.getParameter("uname");
String emailid=request.getParameter("email");
out.print("Name="+name);
out.print("Email-Id="+emailid);
session.setAttribute("user",name);
session.setAttribute("email",emailid);
<a href="second.jsp">Click to go second jsp </a>
%>
</body>
</html>
second.jsp
<html>
<body>
<%
String name=(String)session.getAttribute("user");
String emailid=(String)session.getAttribute("email");
out.print("Name="+name);
out.print("Email-Id="+emailid);
%>
</body>
</html>
[…] session Object […]
LikeLike