Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invalidate session in HttpSessionBindingListener

843841Aug 10 2007 — edited Aug 17 2007
Hi all,

Hi,

Currently, i am facing a difficulty in invalidating a session in a class that has implemented HttpBindingListener. The purpose of this is to invalidate the session when the session timeout is reached.

When i wrote the following codes, it gave me an exception.
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

      HttpSession sessNew = request.getSession(true);
      request.setAttribute(usrID,sessNew);

      sessNew.setMaxInactiveInterval(sessTimeOut);
      sessNew.setAttribute("TimeoutSession", new SessionTimeoutListener());
}
public void valueUnbound (HttpSessionBindingEvent event){
   try{
     if(event.getSession() != null){
          HttpSession sess =event.getSession();
          sess.invalidate();
   
   catch(Exception ex){
      ex.printStackTrace();
      System.out.println("Exception occurred");
   }
}
So is there anyway for me to invalidate the session in this case? Your reply is much appreciated.

Thanks,

Regards,
Pak Kin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2007
Added on Aug 10 2007
4 comments
186 views