Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Adrian Burlington
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • 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:


//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?
Paul Clapham
Posts: 22374
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!