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()
posted 12 years ago
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?
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
Do not set lab on fire. Or this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java