dcsimg
Session Invalidation Problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   S_Sadeqa
Posted On:   Saturday, January 19, 2002 06:08 AM

I am developing a site using JSP, in which I have to do some work just before session invalidation. I have defined a class SessionTimeout(it implements HttpSessionBindingListener), and added its object to the session. when object is bound to the session then valueBound() method is called properly but when session is invalidated then valueUnbound() method is not doing the work tht I have defined in it. It is proved tht session is invalidated: because, If I want to rejoin session after timeout or in another browser then it gives me exception: java.lang.IllegalStateException: Session cwlw0dll.5be5 is invalid. ) If there is any mistake then Please g   More>>

I am developing a site using JSP, in which I have to
do some work just before session invalidation.
I have defined a class SessionTimeout(it implements
HttpSessionBindingListener),
and added its object to the session.
when object is bound to the session then valueBound()
method is called properly but when session is
invalidated then valueUnbound() method is not doing the
work tht I have defined in it.

It is proved tht session is invalidated:
because, If I want to rejoin session after timeout or in another browser then it
gives me exception:
java.lang.IllegalStateException: Session cwlw0dll.5be5 is invalid. )


If there is any mistake then Please guide me.




----------
login.jsp
----------
<% jsp:useBean id ="monitor" scope="application" class="java.util.HashMap"/>


String user=request.getParameter("id");


String upw=request.getParameter("pw");

// ... code checks Authentication


if(monitor.containsKey(user))

{

HttpSession oldSession = (HttpSession)monitor.get(user);

oldSession.invalidate();

}


session.putValue("user",user);


SessionTimeout To=new SessionTimeout();

session.putValue("To",To);


monitor.put(user,session);

System.out.println("Assigned new session for:"+user);


session.setMaxInactiveInterval(60);


%>



-------------------

SessionTimeout.java

-------------------


import javax.servlet.http.HttpSessionBindingListener;

import javax.servlet.http.HttpSessionBindingEvent;

public class SessionTimeout implements HttpSessionBindingListener{


public SessionTimeout()

{

}

public void valueBound(HttpSessionBindingEvent event)

{

//say,

System.out.println("Bound");

}

public void valueUnbound(HttpSessionBindingEvent event)
{

//say,

System.out.println("UnBound");

}

}







-----------

signout.jsp

-----------

<%

String user=null;

if(session != null)

{

user=(String)session.getValue("user");

if(user != null)

{

HashMap hash=(HashMap)application.getAttribute("monitor");


HttpSession user_sess=(HttpSession)hash.get(user);

hash.remove(user);

session.invalidate();

user = null;

}

}

%>

   <<Less

Re: Session Invalidation Problem

Posted By:   sandeep_karnwal  
Posted On:   Sunday, April 14, 2002 06:26 AM

Infact I am facing the same problem have you got any solution. Pl let me know if you have got any solution of this.
About | Sitemap | Contact