❮ Previous Next ❯

JSP session implicit object

The session is an implicit object of type javax.servlet.http.HttpSession and behaves exactly the same way that session object behave in Servlets. The developer use this object to set, get or remove attribute or to get session information.
Example;

index.html

<html>
<body>
<form action="welcome2.jsp">
<input type="text" name="uname">
<input type="submit" value="ok">
</form>
</body>
</html>

welcome2.jsp

<html>
<body>
<%
String str=request.getParameter("uname");
out.print("Welcome "+str);
session.setAttribute("user",str);
<a href="welcome3.jsp">welcome3 jsp page</a>
%>
</body>
</html>

welcome3.jsp

<html>
<body>
<%
String str=(String)session.getAttribute("user");
out.print("Hii "+str);
%>
</body>
</html>

❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved