0

Event close and session invalidate

asked 2011-06-22 02:46:44 +0800

Marky gravatar image Marky flag of Spain
284 7
http://www.no/havent-doma...

Hi forum!
Few days ago I show the problem with the explorers about the event closing. I think about this because it's a problem to control the session of users in our programs.
I try to create a class to control it and I want that you tell to me the possibles warnings or problems to use it.
Say this:
Everytime that we open a new desktop we add attribute called live, and we add the desktop into a List<Desktop> and this List into the scope of Sessions. Then, a timer call a method to check if every Desktop has this attribute. If one of this desktops answer affirmatively, we keep the session, but if anyone answer we invalidate de session.
This works, but i want know what problems can make.

This is the code:


public void onCreate$Window(){	
			//setAtrtribue to Desktop
			Executions.getCurrent().getDesktop().setAttribute("live", "ok");
			 
			//add desktop to list
			 if(Executions.getCurrent().getSession().hasAttribute("lista")){
				 lista = (List<Desktop>) Executions.getCurrent().getSession().getAttribute("lista");
				 lista.add(Executions.getCurrent().getDesktop());
				 Executions.getCurrent().getSession().setAttribute("lista", lista);
			 }
			 else{
				 lista= new ArrayList<Desktop>();
				 lista.add(Executions.getCurrent().getDesktop());
				 Executions.getCurrent().getSession().setAttribute("lista", lista);
			 }
			
		}


public boolean comprueba()  {
lista = (List<Desktop>)Executions.getCurrent().getSession().getAttribute("lista");
		for(Desktop desktop : lista){
			escritorio = desktop;
			if(escritorio.hasAttribute("live")){
				return false;
			}
		}
		return true;
	}


public void darVuelta(){
		if(comprueba()){
			Executions.getCurrent().getSession().invalidate();
		}
	}

then a timer from tomcat calls darVuelta()

is it feasible?

Thanks for all,
Marky

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2011-06-22 04:56:25 +0800

Marky gravatar image Marky flag of Spain
284 7
http://www.no/havent-doma...

updated 2011-06-22 06:03:16 +0800

Sorry, I forget this declaration:

	        private Desktop escritorio ;
		private List<Desktop> lista;

If anybody has other form to detect the end of sessions please write it!

Thanks all!

Marky

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-06-22 02:46:44 +0800

Seen: 380 times

Last updated: Jun 22 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More