I want to a jsp program which displays all CURRENTLY loggied on users. So I
want to A.jsp to populate login info (basically login names) to a global
hashtable. 

Then I need a bean B.java(NOT jsp) which implements HttpSessionListener to
get the login information from A.jsp and process them. If user log out or
session expires. the sessionDestroy method will delete that user from the
global hashtable. 

Then, I need C.jsp to display the currently logged on users.

So far I can only populate the hashtable but CAN NOT remove any user when
the user's session invalidated. So even a user logged out, the user still
get displayed in C.jsp.

I think the B.java has a problem establishing the reference of the hashtable
in the bean... 


Please, please help.

The following is the codes I have:

A.jsp(login page)
============================================
 Š..

<jsp:useBean id="user" scope="application"class="java.utilHashtable"/>

user.put(session.getId(), loginName)

Š..
==============================================


B.java
============================================
package xxx.xxx.xxx;

import java.util.Hashtable;
import javax.servlet.ServletContext;
import javax.servlet.http.*;

import java.util.Hashtable;
import javax.servlet.ServletContext;
import javax.servlet.http.*;

public class sessAdmin implements HttpSessionListener
{  private String loginName;
   Hashtable ht=null;
   public void sessionCreated(HttpSessionEvent ev)
   { }
   public void sessionDestroyed(HttpSessionEvent ev)
   { ht=(Hashtable)ev.getSession().getServletContext().getAttribute("user");
     String id=ev.getSession().getId();
     if(ht.containsKey(id))
     {   ht.remove(ev.getSession().getId());
     }
     System.out.println("user "+ ht);
   }
}
============================================

C.jsp (display page)
==============================================
<[EMAIL PROTECTED] language="java" %>

<[EMAIL PROTECTED] import="java.io.*,java.sql.*,java.util.*,javax.servlet.*" %>

<jsp:useBean id="user" scope="application"class="java.util.Hashtable"/>

<%=user%>

OR some kind of display method....

============================================



RD

==========================================================================To 
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to