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
David Brafford
Ranch Hand
Joined: Feb 11, 2001
Posts: 91
posted
0
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
Tracy Woo
Ranch Hand
Joined: Jul 23, 2002
Posts: 113
posted
0
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
Joined: Jul 11, 2002
Posts: 72
posted
0
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 -
Anthony Villanueva
Ranch Hand
Joined: Mar 22, 2002
Posts: 1055
posted
0
Hi Thomas, here is some sample code in case you are interested.
Thomas Rochon
Ranch Hand
Joined: Jul 11, 2002
Posts: 72
posted
0
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 -