Hassan,

How do I add an instance of the listener to each session?  Can you please 
provide an example?

I forgot to mention that I already have the following in the first JSP after 
the login is validated:

<jsp:useBean id="listener" class="abcd.AbcdSessionListener" scope="session" />

<%
session.setAttribute("sessionListener", listener);
%>


What you say, "...and that object receives the event, it still knows its attributes."  
What do you mean by "object"?  Which object?

Thanks.


Hassan Schroeder wrote:
Franklin Phan wrote:

I'm trying to code a method to clean up specifically named files inside a working dir (in Windows XP) whenever the session times out.


Rather than a global listener approach, why not just add an instance
of your listener *to each session*? When the session ends and that
object receives the event, it still knows its attributes; from your
example:

 public void valueUnbound(HttpSessionBindingEvent se) {
    AbcdUtil util = new AbcdUtil();

    /* -- neither of these is necessary, as userId is still defined
     *   HttpSession session = se.getSession();
     *   String userId = (String)session.getValue("userId");
     */

I use this approach to return items to stock from an abandoned (via
session timeout) shopping cart, for instance.

FWIW!


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to