This JSP shows simple principles of session management
by incrementing a counter each time a user accesses a page.
<%!
private int totalHits = 0;
%>
<%
session = request.getSession(true);
Integer ival = (Integer)session.getAttribute("simplesession.counter");
if (ival == null)
ival = new Integer(1);
else
ival = new Integer(ival.intValue() + 1);
session.setAttribute("simplesession.counter", ival);
System.out.println("[SessionTest] count = " + ival );
%>
<%
Integer cnt = (Integer)application.getAttribute("simplesession.hitcount");
if (cnt == null)
cnt = new Integer(1);
else
cnt = new Integer(cnt.intValue() + 1);
application.setAttribute("simplesession.hitcount", cnt);
//System.out.println("[SessionTest] count = " + ival );
%>
You can change the time interval after which a session times out. For more information, see the Session Timeout section under Using Sessions And Session Persistence in Web Applications.
Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
Failover Test Uhahahahah!!! hey!!! Don't sleep... it's HomeWork!!!!
ServerName :
<%
String instName=System.getProperty("weblogic.Name");
%>
<%=instName%>
You have hit this page <%= ival %> time<%= (ival.intValue() == 1) ? "" : "s" %>,
The value in red is stored in the HTTP session (javax.servlet.http.HttpSession), in an object named simplesession.counter. This object has session scope and its integer value is re-set to 1 when you reload the page after the session has timed out.
before the session times out.
You have hit this page a total of <%= cnt%> time<%= (cnt.intValue() == 1) ? "" : "s" %>!
The value in green is stored in the
Servlet Context (javax.servlet.ServletContext), in an object named simplesession.hitcount. This object
has application scope and its integer value is incremented each time you
reload the page.