Somehow notify a specific user of chat file modification on his ajax call.
Hello.
I am creating a web based chat app.
If Mary talks to Joe through this app a file is created (daily) as they converse I insert each message at the top of said file.
I use an ajax call to scan the file contents and also get each users presence(logged in , logged off, etc..).
All works fine.
I need a way to notify Joe that he has a message from Mary (So that I can alert him as to a message waiting). I dont want to have to iterate through all files in the chat directory to find a file with Joe (file names are named Joe_Mary-Jul13.xml) and then determine if the file has been updated. I thought that there would be a way to either modify Joe's session (?) or perhaps store something(List, StringBuffer, not sure) in memory so that when joe's ajax call is initiated I can scan memory(or whatever) as to message waiting status?
So lets say Mary types "hello joe" I write this to Joe_Mary-Jul13.xml along with a timestamp....at the same time I write to something in memory. Now during joe's ajax call he checks this place in memory to determine if he has any messages waiting.
Can this be done using a bean, servlet, StringBuffer, etc... or should I just create a single file that holds all new message statuses(dont really want to do this)?
Thanks for any ideas!!
Sorry if this is confusing.

