Session Attribute Present Even after removing the same in Servlet -


i removing attribute session in logoutservlet. in servlet(logoutcheckservlet) trying same attribute , still present. please me find reason same.

logoutservlet

public class logoutservlet extends httpservlet {

/**  *   */ private static final long serialversionuid = 1l;  protected void dopost(httpservletrequest request, httpservletresponse response) {      httpsession session= request.getsession(false);     if(session.getattribute("userinfo")!=null) {          system.out.println("in logout");         session.removeattribute("userinfo");         session.invalidate();         system.out.println("in logout");     }     try {         response.sendredirect("http://localhost:8080/loginpoc/jsp/login.jsp");     } catch (ioexception e) {         // todo auto-generated catch block         e.printstacktrace();     }    } 

}

logoutcheckservlet

public class sessioncheck extends httpservlet {

/**  *   */ private static final long serialversionuid = 1l;  protected void dopost(httpservletrequest req, httpservletresponse resp) {     resp.setcontenttype("text/xml");     string response=null;     usersessioninfobean bean=null;     try {         system.out.println("in session check");         httpsession session= req.getsession(false);         /*         if (session.isnew()){             system.out.println("new");             system.out.println("new session id:"+session.getid());             system.out.println("new creation time:- "+session.getcreationtime());         }         else{             system.out.println("old");             system.out.println("else session id:"+session.getid());             system.out.println("else creation time:- "+session.getcreationtime());         }*/         bean=(usersessioninfobean)session.getattribute("userinfo");         system.out.println(bean.getfullname());         if (bean.getfullname()==null){             response = "<?xml version=\"1.0\" encoding=\"utf-8\"?><root>n</root>";             system.out.println("if block");         }             else{             response = "<?xml version=\"1.0\" encoding=\"utf-8\"?><root>y</root>";             system.out.println("else block");          }         resp.getwriter().println(response);     } catch (ioexception e) {         // todo auto-generated catch block         e.printstacktrace();     }     finally{         bean=null;     } } 

}


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -