?
Solved

Can I rely on Session-Timeout to call valueUnbound() ?

Posted on 2003-03-06
9
Medium Priority
?
812 Views
Last Modified: 2013-11-24
I read the servlet specs 2.2 - 2.4, but I'm unsure if it's required for a Container to unbind all values of a session when invalidating it as a result of a session timeout. (that is: valueUnbound() will be called)

I tested that with tomcat 4.1.18 and it works, but can I rely on this in terms that it is a required behaivor?

Thanks,

Jan
0
Comment
Question by:NetWize
[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
  • 4
  • 4
9 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 8079235
It seems that according to the spec, YES, valueUnbound() SHOULD be called.

If it is not...it is a bug in the container, and there's no accounting for that :-(
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8079242
How can my application get to know when a HttpSession is removed (when it time- outs)?

Define a class, say SessionTimeoutNotifier, that implements
javax.servlet.http.HttpSessionBindingListener. Create a SessionTimeoutNotifier object and add it to the user session. When the session is removed, SessionTimeoutNotifier.valueUnbound() will be called by the servlet engine. You can implement valueUnbound() to do whatever you want.

[from http://trinetra.ncb.ernet.in/~chandu/resources/Java/JSPFAQ.pdf]
0
 
LVL 3

Author Comment

by:NetWize
ID: 8079422
Thank's so far, but it gets even worse:

Do I have any chance to let the container inform me of the session invalidation within a given timeframe?
I noticed that the actual removal takes longer than the value passed to setMaxInactiveInterval(). So this will depend on how the server checks invalid sessions and that doesn't suite my needs i think.
Or are these checks required to be done in a given time?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
DynaPete earned 200 total points
ID: 8081014
In my experience, valueUnbound is invoked near enough to session inactivation time that I believe they use a notification algorithm rather than a polling algorithm.  What were your test results?
0
 
LVL 3

Author Comment

by:NetWize
ID: 8081275
Ok, that's good to know.

What Application-Servers are covered by that experience? My webapp should at least run on timcat, jboss (these i tested myself), weblogic 5 to 7 and websphere.
0
 
LVL 3

Author Comment

by:NetWize
ID: 8081286
Ah and test result showed that a 2-minute timeout took from 2:10 to 3:30 wich is not good but acceptable.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8081455
Yay!  Timcat! ;-)

Java is not a Real Time Language, you can only suggest when things should timeout, not enforce it :-/  People are working on a Real Time JVM, but I wouldn't hold your breath...

As Tomcat and JBoss are free, and Weblogic and Websphere cost cash, I would expect it to work on all of them...  if not, by buying a copy of the other two (which someone will have to do to test it), I assume you will have the right to ask them why not! :-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8081460
PS:  DynaPete should get the points for this Q :-)

He has had experience, I just cut and paste the web ;-)
0
 
LVL 3

Author Comment

by:NetWize
ID: 8086758
Thank you, I feel much better now removing the timeout-threads that someone inserted into the program long time ago and that didn't work properly...

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month9 days, 6 hours left to enroll

764 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