• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setMaxInactiveInterval() finalize()

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there !
Maybe that question occured somewhere else
in this faq. But I didn't found it.
So - Here is my problem :
I create a session object in a servlet class.
I set the MaxInactiveInterval of the session
object to 15 minutes.
After the 15 minutes have expired the servlet should call a method. I put the method finalize()
into the servlet. Looks something like that:
protected void finalize() {
// call a method
}
The problem is, after 15 Minutes (30 minutes, whatever) nothing happens. No method call and even no System.out. Nothing.
So - What's wrong ?
Cans please someone help me ?
Thanx !
Thomas
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Servlet version does your web container
support?
If 2.3, you can use an HttpSessionListener to
listen when a session is created, and when a
session is destroyed.
void sessionCreated(HttpSessionEvent e)
void sessionDestroyed(HttpSessionEvent e)
The new LifeCycle events were added in the
Servlet 2.3 specification
-------------------------------------------
Considering the Certified Java Programmer Exam?
Get JCertify!
Now available for Exam 310-035 and 310-025
http://www.enterprisedeveloper.com/jcertify
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Thomas Rochon:
After the 15 minutes have expired the servlet should call a method.


Why should the servlet call a method??? When the session expires, the servlet container will call sessionDestroyed() on a HttpSessionListener [needs to be configured in the DD]
Also, finalize() on the servlet will not be called till the servlet object is about to be destroyed by the GC. You should not depend on that. And it has nothing to with sessions anyway.
 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies !
I'll try to solve the problem with the HttpSessionListener, like David told me. I red some tutorials on that and it sounds like that's the right way to go.
I'm very new with java, servlets a.s.o. .
So please keep your fingers crossed that I'll get it
Thanks a lot !
- Thomas -
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thomas, here is some sample code in case you are interested.
 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ups - Today I noticed that you posted a reply to my Question. Well it's long ago. But .... Thanx )
I had to solve the problem another way, because the Websphere Application Server I'm using doesn't suppoert the servlet 2.3 spezification yet.
But thanx for your reply )
- Thomas -
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic