I am doing something quite convoluted to count sessions (I use Resin 1.2b1
and getSessionContext() always returns null)...
I create a session bean that implements HttpSessionBindingListener. I pass
the servlet context of the servlet/jsp that creates the bean to the
contructor of the bean. The valueBound() method of the bean uses the
servlet context to access an application scope attribute which holds the
session count (and increments the count). The valueUnbound() method uses
the same context (this might or might not be dangerous - can the context
change between the time the bean is instantiated and the time it is
destroyed??) to decrement the application scope attribute. This method
seems to work both when you call session.invalidate() and when a session
times out. Again, I'm not sure how it work after container restarts and in
other 'strange' instances.
Donald
----- Original Message -----
From: "Shiraz Wasim Zaidi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 26, 2000 9:56 PM
Subject: Re: Session counting and "global.asa" equivalent?
>
>
> >I'm trying to figure out how to capture the number of active sessions on
my
> >site, but am not sure how.
>
> Enumeration activeSessionids = session.getSessionContext().getIds();
> will give you ids of all active session.
>
> Note: HttpSessionContext is deprecated interface in JSDK2.2.
>
> -Shiraz
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets