Hello,
I have made a HTML chat using JSP/Beans and everything is working fine in chat.What i am not able to work out is how to remove a user from the chatusers list as soon as the user closes the browser.i didn't find anything in javascript to trap the closing of browser.
Another solution in my mind is if I can trap the expiry of sessions then as soon as the session expires then the session user will be removed from the users list.But don't know how to trap that as when the user closes the browser his session automatically invalidates.
I am using a bean chatUsers storing all the chat users.
and in jsp i have used application scope to make this bean data of application level so that user added from any browser remain in chatusers list(or I can declare static Vector chatUsers in chatUsers class)If I remove the application scope then only current chat user is shown,so i have made the scope to application so that all users share same bean object and data will be persistent.But once a user name is stored then when the user closes the browser and leaves the chat,still it is showing his name in users list beacuse it is of application level and recreates the list only when the application starts again -there I stuck up how to trap this closing of browser and remove that user from the chatUsers list stored in the bean.
On sites i have seen as soon as the user closes the browser he is removed from the users list,but i'm not able to work out how to implement this ,where should i call the removeUser function and when to call it.
Any immediate help will be highly appreciated.
<jsp:useBean id="chatUsers" scope=application class="chat.chatUsers"/>
Thanks In Advance
Regards
Rashmi
Discussions
Web tier: servlets, JSP, Web frameworks: developed a chat with JSP/beans -stuck up somewhere need Help
-
developed a chat with JSP/beans -stuck up somewhere need Help (7 messages)
- Posted by: Rashmi Gupta
- Posted on: June 28 2001 05:27 EDT
Threaded Messages (7)
- developed a chat with JSP/beans -stuck up somewhere need Help by Sreenivasa Murthy on June 28 2001 07:13 EDT
- need help by sumeet saraf on October 11 2004 07:29 EDT
- developed a chat with JSP/beans -stuck up somewhere need Help by Shahzad Masud on June 28 2001 08:45 EDT
- chat using bean by sumeet saraf on October 12 2004 00:38 EDT
- developed a chat with JSP/beans -stuck up somewhere need Help by rewr rewr on June 28 2001 11:14 EDT
- developed a chat with JSP/beans -stuck up somewhere need Help by Sweety Verma on June 29 2001 01:23 EDT
- developed a chat with JSP/beans -stuck up somewhere need Help by Subhash K on October 13 2004 06:36 EDT
-
developed a chat with JSP/beans -stuck up somewhere need Help[ Go to top ]
- Posted by: Sreenivasa Murthy
- Posted on: June 28 2001 07:13 EDT
- in response to Rashmi Gupta
hi rashmi
i got ur problem, but can u tell where ur storing all the
users, do u have written any methods for adding/removing.
pl mail ur bean code , i will try my best to help
sri_murthy at hotmail dot com
thanks
-
need help[ Go to top ]
- Posted by: sumeet saraf
- Posted on: October 11 2004 07:29 EDT
- in response to Sreenivasa Murthy
hi rashmi..
this is sumeet ..can u give me the soource code of chat program
i will be grateful to u..it is very urgent...
thanks..
bye take care -
developed a chat with JSP/beans -stuck up somewhere need Help[ Go to top ]
- Posted by: Shahzad Masud
- Posted on: June 28 2001 08:45 EDT
- in response to Rashmi Gupta
I have faced the same problem which you are facing .. The solution which I adopt was some thing like this.
1. I have created a session listner class that listen the active session object after a specified amount of time. That time can be set in the server configuration side.
2. For user logging, I have created hash table .. not vector. Using hash is little more easy than Vector.
3. I did not know how to capture the close window event so I have adapted this solution. I don't know whether there is a window close event or not ?
4. I have changed my application to look like log in and log out type. It helps me in activity monitoring of the user as well. Like which room he joined or from which room he was kicked or banned. All that information is traced on activity monitoring.
5. When ever the session lisnter indicate the time up and user did not do any activity then just log that user out of the application. I am sure that you have security check , whether a non log in person can enter into website.
Well, that's all. I don't know whether this solution is optimized or understandable to you. I think , I made myself clear.
shozi
-
chat using bean[ Go to top ]
- Posted by: sumeet saraf
- Posted on: October 12 2004 00:38 EDT
- in response to Shahzad Masud
hi rashmi.
can u give me ur source code for bean..so that i can do rnd and come up with a solution...even thopugh u have a solution..plz send me the cofde it is urgent
..plz mail me at sumeet.saraf@rediffmail.com -
developed a chat with JSP/beans -stuck up somewhere need Help[ Go to top ]
- Posted by: rewr rewr
- Posted on: June 28 2001 11:14 EDT
- in response to Rashmi Gupta
Implement the HttpSessionBindingListener interface in your class.When the user closes the browser,the session expires and the valueunbound() is called.Get the session(using getSession) and remove the corresponding userId from your Vector.It might be better to use a Hastable rather than a vector to store the info.
-Prakash -
developed a chat with JSP/beans -stuck up somewhere need Help[ Go to top ]
- Posted by: Sweety Verma
- Posted on: June 29 2001 01:23 EDT
- in response to Rashmi Gupta
Hello everybody,
Thanks for ur responses.I have found onUnload() function to trap the closing of browser.
Called the removeUser()javascript function (placed the code of removing the user in this function)from onUnload() and get the things running.
<body onUnload()="removeUser()">
now when the user closes the browser code written in removeUser() gets executed and the user name picked up from the session is removed from the bean by calling the removeChatUser(chatName) bean function.
Thanks
Rashmi
-
developed a chat with JSP/beans -stuck up somewhere need Help[ Go to top ]
- Posted by: Subhash K
- Posted on: October 13 2004 06:36 EDT
- in response to Rashmi Gupta
<html>
<body onLoad="closing=true" onUnload="if (closing) window.open('C:/testJava/test2.htm','newwin');">
CLOSE IT TO OPEN
</html>
if u think its fine...just reply to my mail id...else if u got the soln do mail me that...
thnx
regds
Subhash.K