• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

servletContext or application-trying to post a message so all end users of the app can see the post

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

So far I have been using the HttpSession to provide the end-user some information that *S/HE* was doing (Example, user clicked a cart - I can tell him/her whats in the cart).

I was wondering what mechanism should I use inorder to provide information to ALL users. Consider the following scenario: I'm the administrator (type of user) of the application and I wish to inform anyone who's right now using the application about something ( a message/post ).

I read that ServletContext (or application ?!? ) can do the job. But I'm not sure. How can a user write something that anyone who's using the system can see that (say in the header)? I'm looking for something like this:

Action:


//this of course doesn't really works. (I'm paraphrasing from httpsession -- <s:property value="%{#session.SER_IN_SESSION.loginName}"/>)


So once the action is performed - all end-userS should see the message "data comes here 1.2.3"

can anyone put more light, am I on the right track?
THANK YOU!
 
Sheriff
Posts: 28322
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems to me there's two separate questions here:

1. How to put the data in a place where all users of the application can see it

2. How to make sure that all users of the application actually see it

The second question exists because a user of the application can't see any new information until they send a request to the server. The response sent from the application could then include this message.

So that implies two things:

1. You should store this message in the application context, which is common to all users.

2. Servlets which send responses should include this message, if it's present.

If you have further requirements, such as each user should only see the message once, then you'll need to build more logic into the part which sends the message and perhaps more logic into the part which stores the message into the application context.

Edit: I don't think you would use the context's initialization parameters for this, unless the message is a permanent one which is set up when you release the application. The context has attributes, if I recall right. I would use one of those if the message is going to be created long after the application starts up.
 
It's never done THAT before. Explain it to me tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic