Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Application variable

 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my current web applicatin has to be filled with application scope variables, what is the best way to handle it. Is it possible to place a bean or serialsed bean on the context(application scope) ... every operation is based on application variable only so there will be lot of data changes in it...

eg i want to store all the user who are login and using the web application , and many such details ...

everything i want to store in the application scope instead of cookies or sesssion.

Can anyone tell me best practise for it?

i want to store in a place like servlet context....
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Not able to make out..
Could you please elaborate with an example?



 
Kalyan Ram
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind Subramanian wrote:
everything i want to store in the application scope instead of cookies or sesssion.

Can anyone tell me best practise for it?

javax.servlet.http.HttpSession (J2EE 1.4)

Session information is scoped only to the current web application (ServletContext), so information stored in one context will not be directly visible in another.

Doesn't that suffice?

I think I am in the same place as the parent
 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i want to store in a place like servlet context....
 
Mark Williams
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is best practice or not but maybe you could create a class with a static method that creates an instance of the class when called the first time and returns only that instance when called every time after that? I think this is the idea behind the singleton pattern... Anyway, that instance could hold any application wide variables.
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming the problem:

You can store the data in application context where all the user/request need to access.
Example :
System parameters.
EJB home/ejb objects cache.

This is are all static data available to all the users.

It depends what exactly you need to keep in application context.Then only we can decide the best practice.


 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the discussion.. i completed my latest portal , with help of servlet context. what i tried to achieve was the interaction between the different user who are using the portal without the help of DB. i stored the each user in the context and make the other user to read from it about their status....


thanks for all and javaranch....
 
Oh. Hi guys! Look at this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!