Meaningless Drivel is fun!
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
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

Message/Alert exchange in Web App using ServletContext

Yuri Klind

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
I agree. Here's the link:
subject: Message/Alert exchange in Web App using ServletContext
It's not a secret anymore!