Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-06
9
Medium Priority
?
836 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
  • 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
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.

 

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

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.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

579 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