Hi all!

I have an application with a Controller Servlet which is invoked every time
a user request arrives to redirect to a specific JSP.

What I want to do is displaying a special information page, when the session
of a user expires.

Therefore I use the following code in the controller servlet:

    HttpSession session = request.getSession(true);

    System.out.println("FrontComponent - Session id: " + session.getId());

    if (session.isNew()) {

      System.out.println("Session " + session.getId() + " is new.");
      System.out.println("Seconds until session times out: " +
session.getMaxInactiveInterval() + " s");

      session.setAttribute("sessionState", new JSPSessionState());
   }

The JSPSessionState object implements HttpSessionBindingListener and
provides the implementation of the following methods:

  public void valueBound(HttpSessionBindingEvent event) {
    System.out.println("JSPSessionState - bound to session " +
event.getSession().getId());
  }

  public void valueUnbound(HttpSessionBindingEvent event) {
    System.out.println("JSPSessionState - unbound from session " +
event.getSession().getId());
  }

I use Tomcat v3.3 as servlet engine and I have set the session timeout
interval to 1 minute.

What I do now is starting the application, and request a page. The servlet
tells me the id of my session and that it is a new one. So far, so good.
Then I wait longer than a minute. The session times out, I do another
request and now I have another session id, also a new one.

What I don't understand is:

The method valueBound() is called when I start a session but the method
valueUnbound() doesn't seem to be called when the session times out because
there'e nothing written to standard out.

What am I doing wrong?

Perhaps someone can help me here. Thanks in advance.

Stefan


Novedia AG, Stefan Aigner
Hardenbergstrasse 19, D-10623 Berlin, Germany
tel:+49.30.311889-0, fax:+49.30.311889-19
mailto:[EMAIL PROTECTED], http://novedia.de

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to