| Author |
Simple messaging for a j2ee application MVC
|
EM. Lashkar
Greenhorn
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 .
|
ML
|
 |
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
|
|
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?
|
A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
|
 |
Kyle Brown
author
Ranch Hand
Joined: Aug 10, 2001
Posts: 3879
|
|
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
|
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Simple messaging for a j2ee application MVC
|
|
|