Just curious... is there a way to get a list of sessions that are active?
Maybe from the ServletContext or something?

Regards,
Daniel


-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED] Behalf Of Ozgur
Sent: Monday, 12 April, 2004 7:57 PM
To: [EMAIL PROTECTED]
Subject: Re: how to implement Who's Online ??


You can write a Sesion Manager class (see below) and define it into
web.xml as a listener.

public class SessionManager implements HttpSessionListener {
     private static int activeSessions = 0 ;
     public void sessionCreated(HttpSessionEvent se) {
          activeSessions++ ;
          String SessionID = se.getSession().getId() ;
          String TimeCreated = getFormattedDate(new
Date(se.getSession().getCreationTime()), "yyyy-MM-dd H:mm:ss") ;
          System.out.println("Created: " + se.getSession().getId() + " :
" +
                             new
java.util.Date(se.getSession().getCreationTime())) ;
          System.out.println("Created: " + activeSessions) ;
     }

     public void sessionDestroyed(HttpSessionEvent se) {
          if (activeSessions > 0)
               activeSessions-- ;
          String SessionID = se.getSession().getId() ;

          System.out.println("Destroyed" + SessionID) ;
          System.out.println("Destroyed: " + activeSessions) ;
     }
}

Regards,

Ozgur ..


-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED] On Behalf Of
majid nakit
Sent: Monday, April 12, 2004 8:07 AM
To: [EMAIL PROTECTED]
Subject: how to implement Who's Online ??


Hi,
lot of websites show who is online, some show how many
guest and how many registered.
could you please show me how to do it ?
thanks your help is appreciated.


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/

________________________________________________________________________
___
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to