File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Simple messaging for a j2ee application  MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Simple messaging for a j2ee application  MVC " Watch "Simple messaging for a j2ee application  MVC " New topic

Simple messaging for a j2ee application MVC

EM. Lashkar

Joined: Jan 31, 2003
Posts: 9
Hi ,
I have a web application ( DBBeans --Servlet --JSP) .
I need to incorporate a functionality such that:
if the admin needs to send out a message to the app-logged in users , for example : "Application will shutdown in 10 mins. Please save your work and logout of the app: Message8" and can control the number of times this message is shown to a any users, how can I do that in the app without using a full blown messaging service (JMS, MQSeries) .
For now, I have a property file where I can put a string (example:Message8) which the app will pick up when it loads any of the jsp and show it in an alert box, but I have no way to track/control as to how many times a user should see the message !
Possibly I can modify the code in the controller (servlet) and keep track in a session object but thats still possibly an old way of doing things.
I was thinking of some module like log4j that I could plug into the app for the messaging .
Any suggestion ?
Again , many thanks .

Frank Carver

Joined: Jan 07, 1999
Posts: 6920
It seems to me that the ideal place to track whether a useer has seen a message is in their session.
How about you create a new "message display" object which is placed in every session as it is created, and has a simple method (e.g. show()) which shows a message and increments a count. When the count hist your maximum, or if there is no message, it just shows nothing.
You could either put a call to this "show" method at the top of every JSP, or write a filter which catches every request and does the same thing.
Does that sound reasonable?

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Actually a MUCH better place to put the message (but not the read flag -- see Frank's suggestion) than in a property file is in a ServletContext attribute (the application scope in JSP) which was designed to hold this kind of global information...

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
I agree. Here's the link:
subject: Simple messaging for a j2ee application MVC
It's not a secret anymore!