aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes static class  attibutes vs.  application objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "static class  attibutes vs.  application objects" Watch "static class  attibutes vs.  application objects" New topic
Author

static class attibutes vs. application objects

Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
Hi all
When is recomended to store objects in the instance "application"
and when in on static attributes ?
As example I have a map which contanins the list of diferent sections of the site, when my jsp receives the param "sectionId"
I look in this map to see if I have such key if so, I get the object and display its name amog other things.
Now this work perfect but I have this feeling about using application.put() and application.get() would work better to retrive and store the data
So, when should I use application and when static atrributes ?
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Now this work perfect but I have this feeling about using application.put() and application.get() would work better to retrive and store the data
When you use application scope, you must also need to know
that these variables will be the same in all sessions.
When I say all sessions, it means all sessions of all
users and different sessions of the same user.
These variables can(will be) vary when you re-start your application ie; restart your app server.
Now static variables are a totally different typr of variables.
They have nothing to do with scope. You can have static variables in any scope - application, session, page, or ???

- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
Don't get me started about those stupid light bulbs.
 
subject: static class attibutes vs. application objects