Use Session Jsp : Session « JSP « Java






Use Session Jsp

<%@ page errorPage="errorpage.jsp" %>

<html>
  <head>
    <title>UseSession</title>
  </head>
  <body>
    <%
      Integer count = (Integer)session.getAttribute("COUNT");
      // If COUNT is not found, create it and add it to the session
      if ( count == null ) {
      
        count = new Integer(1);
        session.setAttribute("COUNT", count);
      }
      else {
        count = new Integer(count.intValue() + 1);
        session.setAttribute("COUNT", count);
      }  
      out.println("<b>Hello you have visited this site: "
        + count + " times.</b>");
    %>
  </body>
</html>


           
       








UseSessionJsp.zip( 88 k)

Related examples in the same category

1.JSP: display a session info
2.JSP Session Parameter Rewrite
3.JSP New Session Parameter
4.Jsp Session Cart
5.Jsp Using Bean Scope Session
6.Print the request headers and the session attributes
7.Using Sessions to Track Users
8.Sessions disabled
9.Duplicated session varaibles
10.JSP: view session
11.JSP and session
12.JSP and session 2
13.JSP session counter