?
Solved

Invalidated session does not call HttpSessionListener sessionDestroyed method

Posted on 2004-03-31
9
Medium Priority
?
2,250 Views
Last Modified: 2012-06-27
Hi All,

I've got the following problem:
In my web application a user has to login with username + password. After a successful login I insert a record in a database.
When the user logs out of the application the user Session is invalidated. In my implementation of HttpSessionListener I update the created database record by filling in a logout timestamp.

This mechanism works perfect in Tomcat 4.0.3 running on Win NT.

When I deploy my code to a Linux machine running Tomcat 4.0.3 and 4.0.6 the following happens:
The first time after a tomcat restart that  a user logs in and out the record is created and updated.
The second time however a record is created at login time, but not updated at logout time! Only after 30 minutes (when the session expires) the record is updated with the logout timestamp of that moment.????

Can someone tell me what is happening and may be how I can solve this?

Since the code on both machine is exactly the same I assume it must have something to do with TOmcat configuration or proxies or something.
0
Comment
Question by:paskal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 6

Expert Comment

by:jarasa
ID: 10724253
Hi paskal
can you post the code?
Javier
0
 
LVL 3

Author Comment

by:paskal
ID: 10729815
Yes, I can post the code, but to get the whole thing working I need to post too much code.
And as I said before: it is working in one environment so I assume the code is correct.
But anyway, here is the code of my listener:

public class SessionLogger implements HttpSessionListener
{

   /** Logging object used to log the messages */
  protected static Log logger = LogFactory.getLog(SessionLogger.class);
 
      /**
       * When a new HttpSession is created this method is performed.
       */
      public void sessionCreated(HttpSessionEvent se)
      {
        logger.info("Created: id = "+ se.getSession().getId() );
      }

      /**
       * When a HttpSession is destroyed this method is performed. It will fill the enddate
       * of the session-row in the sessions table if not filled yet.
       */

      public void sessionDestroyed(HttpSessionEvent se)
      {
        endSession( se.getSession().getId());
        logger.info("Destroyed: " + se.getSession().getId());
      }
     
      private void endSession(String id)
      {
         try
         {
           E4AllSession session = new E4AllSession();
                     
           session.setId(id);
       
           DAOSessions dao = new DAOSessions();
           logger.info(" listener: Going to end the session: " + session.getId() );
           dao.endSession(session);
         } catch (Exception e)
         {
             e.printStackTrace();
         }
      }
}

Remark:
The debuig message "listener: Going to end the session..." is also not put out after the second session is (should) killed.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10729870
I would try this to see if the dbupdate was locked for some reason:
      public void sessionDestroyed(HttpSessionEvent se)
      {
        logger.info("Destroyed: " + se.getSession().getId());
        endSession( se.getSession().getId());
        logger.info("delete from db: " + se.getSession().getId());
      }
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Author Comment

by:paskal
ID: 10730899

Okay, guys I finally found it.
Of course the error occurred not where I expected it. The problem was this:
When a user clicked the logout-link or when an unload was done of the html-page I did:
opener.document.location='logout.m'; //or something like that

The first time this action is really performed, but the second time I think it is taken from a cache (of the proxy-server??) and the code is not executed.
On my local environment in Win nT I don't use proxies so no problems with the cache there.

I solved it by doing a post of 'logout.m' request and works now in all environments.

I apologies for the time taken from you looking in to this question. May be better luck next time.

0
 
LVL 6

Expert Comment

by:jarasa
ID: 10730912
:c) Glad you get it.

Javier
0
 
LVL 6

Expert Comment

by:jarasa
ID: 11215998
go ahead.
Javier
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 11244497
PAQed, with points refunded (250)

CetusMOD
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question