Hi i have used the taglib to determine the number of live sessions. but the problem is 
that the sessions get increasing always even if i close one.  
so i added some code in the jsp to invalidate the session 

but the hasMoreElements() returns false always hence not able to invalidate .

any suggestions in this regard is welcome .





/*live.jsp*/
<html><head><title>Live Sessions</title></head>
<body bgcolor=DAF0FE>
<%@ page language="java" import="java.io.*,java.util.*" %>
<%@ page import="javax.servlet.http.HttpSession.*"%>
<%@ page session="true" buffer="8kb" autoFlush="true" errorPage="error.jsp" 
isErrorPage="false" isThreadSafe="true"%>
<%@ taglib uri="../WEB-INF/tlds/live.tld" prefix="liv" %> 
<%
int i=0;
String id="";
HttpSession CID=request.getSession(true);
HttpSessionContext context=CID.getSessionContext();
Enumeration ids=context.getIds();
%>
<%=CID%><br>
<%=context%><br>
<%=ids%><br>
<%=ids.hasMoreElements()%><br>
<%=context.getSession(id)%><br>
<%

while (true)
{
%><%=i%><%
i++;
id=(String)ids.nextElement();
%>Checking <%=id%><%
HttpSession SID=context.getSession(id);
Date da=new Date(System.currentTimeMillis()-24*60*60*1000);
Date ha=new Date(System.currentTimeMillis()-60*60*1000);
Date created=new Date(SID.getCreationTime());
Date accessed=new Date(SID.getLastAccessedTime());

if (created.before(da)) {
%>More than a day old<BR><%
SID.invalidate();
}
else if (accessed.before(ha)) {
%>More than an hour inactive<br><%
SID.invalidate();
}
else
{
%>Still valid<%
}
}
%>
<liv:getLive /> .. 
<liv:getLive id="A"/> 
<%=A%> users online 

</body>
</html>



regards 

ravi kumar
Nrzf%lzjw(Ƞ%#51$Ţb-bڽ.&+anrIH
LDDI0DJ^,rR?^jmj!ڲܢo㲘޲mXmڲܢo鮇nr?}ia
0z^?㲟㲗ڪ;)i08.(ګucm#'^&


Reply via email to