看看javax.servlet.http
Interface HttpSessionBindingListener
其中的两个方法
void valueBound(HttpSessionBindingEvent event)
Notifies the object that it is being bound to a session and identifies the session.
void valueUnbound(HttpSessionBindingEvent event)
Notifies the object that it is being unbound from a session and identifies the session.
Interface HttpSessionBindingListener
其中的两个方法
void valueBound(HttpSessionBindingEvent event)
Notifies the object that it is being bound to a session and identifies the session.
void valueUnbound(HttpSessionBindingEvent event)
Notifies the object that it is being unbound from a session and identifies the session.
在application中建立用户对象,每隔一段时间,用户重置该对象,服务器气动一个线程定期检查该对象
window.open("sss.jsp","","top=2000,left=2000,"),在这个页上再用application.removeAttribute();然后人数减1.你试一下吧,我是这样做的!
具体一点嘛我一定给你分的
<%
OnLine ol = session.getAttribute("myonline");
if (OnLine == null)
{
OnLine oo = new OnLine();
session.setAttribute("myonline", oo);
}
%>
OnLine.javaclass OnLine implements HttpSessionBindingListener
{
public OnLine()
{}void valueBound(HttpSessionBindingEvent event)
//Notifies the object that it is being bound to a session and identifies the session.
{
Integer counter = getServletContext().getAttribute("onlinecounter");
int c = counter.intValue();
getServletContext().setAttribute("onlinecounter",new Integer(c));
}
void valueUnbound(HttpSessionBindingEvent event)
// Notifies the object that it is being unbound from a session and identifies the session
{
基本通上,减少计数器。
}}