Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Invalidated session does not call HttpSessionListener sessionDestroyed method

Posted on 2004-03-31
9
Medium Priority
?
2,263 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
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…
Suggested Courses

636 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