Tomcat sessions user's id list

Discussion in 'Java' started by Rejean, Aug 3, 2004.

  1. Rejean

    Rejean Guest

    Hi,

    I'm looking for how to retrieve the list of user's, log into and
    application in tomcat, via tomcat manager I can see the number of
    sessions, but I need to retrieve the user id of those sessions.

    Thanks!
     
    Rejean, Aug 3, 2004
    #1
    1. Advertising

  2. On 3 Aug 2004 12:28:38 -0700, Rejean <> wrote:

    > Hi,
    >
    > I'm looking for how to retrieve the list of user's, log into and
    > application in tomcat, via tomcat manager I can see the number of
    > sessions, but I need to retrieve the user id of those sessions.
    >
    > Thanks!


    You will have to do some programming - look into the various
    session "Listener" interfaces such as HttpSessionListener.
    Bill


    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
     
    William Brogden, Aug 4, 2004
    #2
    1. Advertising

  3. Rejean

    Rejean Guest

    "William Brogden" <> wrote in message news:<opsb7kvfsnk0yerx@ruby>...
    > On 3 Aug 2004 12:28:38 -0700, Rejean <> wrote:
    >
    > > Hi,
    > >
    > > I'm looking for how to retrieve the list of user's, log into and
    > > application in tomcat, via tomcat manager I can see the number of
    > > sessions, but I need to retrieve the user id of those sessions.
    > >
    > > Thanks!

    >
    > You will have to do some programming - look into the various
    > session "Listener" interfaces such as HttpSessionListener.
    > Bill


    Ok Thanks, I did a little research, created a tag in the web.xml
    <listener>
    <listener-class>
    ca.qc.toto.cop.SessionListener
    </listener-class>
    </listener>


    And created a class
    /*
    * Created on Aug 5, 2004
    *
    * To change the template for this generated file go to
    * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
    Comments
    */
    package ca.qc.toto.cop;

    import java.util.Enumeration;
    import java.util.HashMap;
    import java.util.Map;

    import javax.servlet.http.HttpSessionEvent;
    import javax.servlet.http.HttpSessionListener;

    /**
    * @author cf1926
    *
    * To change the template for this generated type comment go to
    * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
    Comments
    */
    public class SessionListener implements HttpSessionListener {

    private static Map sessions = new HashMap();

    /* (non-Javadoc)
    * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
    */
    public void sessionCreated(HttpSessionEvent arg0) {
    System.out.println("Nouvelle session");
    sessions.put("Nouveau nom","");
    System.out.println(arg0.getSession().getId());

    }

    /* (non-Javadoc)
    * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
    */
    public void sessionDestroyed(HttpSessionEvent arg0) {
    sessions.remove("Nouveau nom");
    }

    /**
    * @return
    */
    public static Map getSessions() {
    return sessions;
    }

    /**
    * @param map
    */
    public static void setSessions(Map map) {
    sessions = map;
    }

    }

    But now I can seem to get the remote user login id .... any ideas.

    Thanks!
     
    Rejean, Aug 5, 2004
    #3
  4. Rejean

    Ashok Swaminathan

    Joined:
    Aug 20, 2007
    Messages:
    3
    HttpSessionListener not generating events

    In my tomcat based test server for a special purpose, ALL listeners are reporting and behaving perfectly, except that the HttpSesssionListener is not reporting a sessionEvent even though the doPost method in the servlet is doing its job perfectly. No error in code, I can assure you.This test is being conducted locally on the same machine.

    Not sessionCreated not sessionDestroyed.

    Any ideas on why HttpSessionEvent is not generated? Or detected? The web.xml for this application deployed is reproduced below in extract.

    </description>
    <servlet>
    <servlet-name>LoadCandidateJSP</servlet-name>

    <servlet-class>tcsi.webcvws.services.web.LoadCandidateJSP</servlet-class>
    <init-param>
    <param-name>readonly</param-name>
    <param-value>false</param-value>
    </init-param>

    <load-on-startup>1</load-on-startup>

    <session-config>
    <session-timeout>1</session-timeout>
    </session-config>
    </servlet>
    <listener>
    <listener-class>
    tcsi.webcvws.services.web.CandidateSessionListener
    </listener-class>
    </listener>


    Thanks
     
    Ashok Swaminathan, Aug 20, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,426
    Luther Miller
    Aug 8, 2003
  2. Daniel Schneller

    [Q] Tomcat sessions

    Daniel Schneller, Oct 10, 2003, in forum: Java
    Replies:
    4
    Views:
    2,923
    Daniel Schneller
    Oct 13, 2003
  3. michel carriere
    Replies:
    2
    Views:
    956
    michel carriere
    Dec 18, 2003
  4. scottymo
    Replies:
    3
    Views:
    778
    Dominick Baier
    Sep 30, 2006
  5. Bookham Measures

    Moving from ASP Sessions to Database Sessions

    Bookham Measures, Jul 23, 2007, in forum: ASP General
    Replies:
    19
    Views:
    606
    Bookham Measures
    Aug 23, 2007
Loading...

Share This Page