• 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
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Application variable

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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



 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i want to store in a place like servlet context....
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
reply
    Bookmark Topic Watch Topic
  • New Topic