posted 17 years ago
Actually, you can configure a <session-config> element
<session-config>
<session-timeout>1</session-timeout>
</session-config>
in your web.xml, so that the session will expire after a period of time. (in mins)
When the user closes the browser, the servlet-api will check on the session, when a session is checked on, it will be created, that's why the sessionCreated() method is called. And I guess in your code, this code never appears as well:
request.getSession(true);
whereas you are manually checking on a session and telling the API even if the session doesn't exists so far, create it anyway specified by the true flag.
So, if you have configured your session timeout, then after you closed your browser, when the specified time expires, say 1 minute, then after a minute, the sessionDestroyed() method will be called.
SCJP 1.4<br />SCJD<br />SCWCD 1.4