my dog learned polymorphism*
The moose likes Servlets and the fly likes Message/Alert exchange in Web App using ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Message/Alert exchange in Web App using ServletContext" Watch "Message/Alert exchange in Web App using ServletContext" New topic
Author

Message/Alert exchange in Web App using ServletContext

Yuri Klind
Greenhorn

Joined: Jul 25, 2004
Posts: 2
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

Joined: Jan 29, 2003
Posts: 8791
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!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
jQuery in Action, 2nd edition
 
subject: Message/Alert exchange in Web App using ServletContext
 
Similar Threads
How can a non-servlet find application root and best way to access a servlets data?
please answer this 128 questions for WLS. Urgently!
Legacy Connectivity ....thanx John and Amanda
Superapp Game
Where can I find John Wetherbie note on Legacy Connectivity