The Artima Developer Community
Sponsored Link

Java Answers Forum
my session is not get invalidate even after executing it in many way

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
ketan patel

Posts: 1
Nickname: k2patel
Registered: Jul, 2004

my session is not get invalidate even after executing it in many way Posted: Oct 27, 2004 8:10 AM
Reply to this message Reply
Advertisement
hi every body
i have problem here and what it is i don't know so please some body help me to find out what went wrong
1. when i create a session the sessionList.java will get execute and it working
2. and when i will call the session.invalidate() it will not going to work or the session destroyed event is not going to execute
3. and when i close the window directly the session not going to destroy after the specified time as specified in the web.xml and login.jsp
the code is as below

web.xml

<web-app>
<listener>
<listener-class>com.samagam.sessionList</listener-class>
</listener>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/mailer-1.1</taglib-uri>
<taglib-location>/WEB-INF/taglibs-mailer.tld</taglib-location>
</taglib>
</web-app>

login.jsp

logged = sessionList.fnd(id);
y = "yes";
if(y.equals(logged)){
if (session.isNew() == false) {
session.invalidate();
session = request.getSession(true);
}
session.setAttribute("userid",id);
session.setAttribute("j",l);
session.setMaxInactiveInterval(300);

}


sessionList.java
[code] 
package com.samagam;
import java.util.HashMap;
import java.util.Hashtable;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
 
public class sessionList implements javax.servlet.http.HttpSessionListener, javax.servlet.http.HttpSessionAttributeListener 
{
  private String name = null;
  private HttpSession session = null;
  private String val = null;
  public static Hashtable tb = new Hashtable();
 
  public void sessionCreated(HttpSessionEvent event)
  {
    session = event.getSession();
    tb.put(session,"0");
  }
 
  public void sessionDestroyed(HttpSessionEvent event)
  {
    session = event.getSession();
    tb.remove(session);
  }
 
  public void attributeAdded(HttpSessionBindingEvent event)
  {
    name = (String)event.getName();
    session = event.getSession();
    val = (String)event.getValue();
    if(name.equals("userid")){
    tb.put(session,val);
    }
  }
   public void attributeRemoved(HttpSessionBindingEvent event)
  {
    name = event.getName();
    session = event.getSession();
  }
 
  public void attributeReplaced(HttpSessionBindingEvent event)
  {
    name = event.getName();
    session = event.getSession();
  }
  public static String fnd(String id){
  boolean i;
  String p;
   i = tb.containsValue(id);
   //System.out.println(i);
   if(i){
   p = "yes";
   return p;
   }else{
   p="no";
   return p;
   }
  }
}
 
[/code]

Topic: my cellRenderer won't work Previous Topic   Next Topic Topic: Looking for Java Programmers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use