Not sure as to when the listener is called in relation to the jsp. I have the listener registered in web.xml and I get the System.out results almost exactly when I load the jsp which only contains the following code for testing.
Is there a way to control when the listener is called?
Perhaps this is not the correct design pattern for what I am trying to accomplish....my thoughts were that this would be a way to generate a listing of all users that are logged into a chat room. Ideas? Thanks for your input.
Seems to me you would get better results by adding the HttpSessionAttributeListener interface to MySessionListener because it has methods that get called when your code does a setAttribute()
Joined: Aug 28, 2003
Thanks, not sure I understand you though. Is it not possible to return an attribute from the listener or is this poor design or both?
Do you have any ideas as to a way to track people when they are in the chat room.
I figured that if I return the getAttribute("userName") and added it to a Application scoped variable (array,List,etc...) I could just print this variable to the page on each subsequent ajax call. Then when the sessionDestroyed method is called I could remove this userName from the variable. Make sense?
Your listener depends upon the JSP to set the scoped variable. Yet what assurances to you have the the JSP has ever been called?
Your design is poor because your listener depends upon the action of a JSP that it has no idea has ever executed or not.
So, how could you break that dependency? [ July 18, 2006: Message edited by: Bear Bibeault ]
Author and all-around good cowpoke
Joined: Mar 22, 2000
The sessionCreated method is called when the session object is created, now when do you think that happens? Answer: It happens BEFORE any of your session related code executes - when the servlet engine creates it before handing a reference to your code. THEREFORE it can't possibly see attributes you set after getting the session instance. Bill