Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Message/Alert exchange in Web App using ServletContext

 
Yuri Klind
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone!
We're looking for a good solution to allow different types of Web app users communicate with each other.
To be more specific, on one side we have regular JSP page users whose actions (login, DB data change) can generate occasional messages/alerts; on the other side we have a different type of users (administrators) who are using Applets to monitor ("real-time") the actions done by JSP users.

The idea we have is to use ServletContext to store a HashMap with messages/alerts. This HashMap is populated when JSP user requests are processed. Administrator's applet is checking the ServletContext HashMap every 5-30 seconds and reads/clears the messages from it.

The only doubt with this approach we see is that ServletContext seem to be designed for static data, loaded once when the Web app is started, while in our case the data is dynamic and needs synchronized access for updates (reads too?).

Not sure if JMS can help here. Seems it can only help with synchronization/locking issues. The JSP user threads can concurrently put messages in JMS queue and Administator�s applet won�t need to worry about synchronous access to ServletContext; but HashMap is synchronized anyway?


Any ideas/comments?
Thank you for your time!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JMS sounds pretty cool here because it is asynchronous and has optional assured delivery. Plus your description of putting data in and getting it out sounds exactly like a queue, less like a map. Oooh, and you could send data from a whole cluster of worker-bee servers to one reporting server.

Now I'm going to shut up and listen as the context map experts weigh in!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic