The reason why we have implemented our own session management was
to be able to keep the session for longer periods of time that were not
provided by a regular servlet session.

We have no public site to view the code but we can send it as an attachment
if you would be interested in looking at it.

Here is the servlet code that starts the Session Manager as a seperate
thread.


public void init(ServletConfig config) throws ServletException {
   super.init(config);

    d_SessionManager = new PCTSSessionManager();
   Thread t = new Thread(d_SessionManager,"SessionManager");
   t.start();
}


Here is the servlet variable for the Session Manager.
private static PCTSSessionManager d_SessionManager = null;





Kevin Mukhar <[EMAIL PROTECTED]>@JAVA.SUN.COM>
Friday January 26, 2001 02:15 PM

Please respond to "A mailing list for discussion about Sun Microsystem's
      Java Servlet API Technology." <[EMAIL PROTECTED]>

Sent by:  "A mailing list for discussion about Sun Microsystem's Java
      Servlet API Technology." <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Session Swapping Error


>From what you've posted there is no obvious thread problem that I can
see. Do you have a public site where we can look at the servlet code?

What are the member variables of the servlet?

You claim the SessionManager runs as a separate thread. How? Where is it
started? How is it accessed?

And purely out of curiosity: Why did you find it necessary to implement
a SessionManager?

Kevin Mukhar

Susie Itzkowitz wrote:
>
> We are not using a class variable like you have mentioned.  However, we
are
> using
> a SessionManager which runs as a seperate thread & is in charge of
adding,
> deleting & retrieving sessions.
>
> Can there be a problem with the SessionManager thread & the servlet
thread
> accessing the session in the following code?
>
> This is the code which creates the collection to store the sessions
> public PCTSSessionManager(long timeOut) {
>    d_Sessions = Collections.synchronizedMap(new HashMap());
>   }
>
> This is the code that retrieves a session for the servlet thread
> public PCTSSession getSession(String userId) {
>    PCTSSession rv = (PCTSSession)d_Sessions.get(userId);
>    if (rv != null) {
>      validateSession(rv);
>      if (rv.isValidSession()) {
>        rv.touch();
>      }
>    }
>    return rv;
>   }
>
> This is the code that adds a session to the collection maintained by the
> SessionManager
> public void addSession(PCTSSession se) {
>    // this would kill another session if the user is already there.
>    synchronized(d_Sessions) {
>      d_Sessions.put(se.getUserId(),se);
>    }
>   }
>
> S Itzkowitz
> [EMAIL PROTECTED]

___________________________________________________________________________
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