wood burning stoves 2.0*
The moose likes Servlets and the fly likes Doubt in Setting the session scope as Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Doubt in Setting the session scope as Application" Watch "Doubt in Setting the session scope as Application" New topic
Author

Doubt in Setting the session scope as Application

ChakraPani Margani
Greenhorn

Joined: Aug 19, 2007
Posts: 17
Hello friends,
First of all thanks to all for giving the support from the starting.
I need a new requirement. I need to call DB2 to get the records for the first time user login and need to maintain
in the application scope. So when the next user comes in, no need to call DB2 again for the records. If the session
is not available then only need to call DB2. Means the first user time only call to database is made. So for next users the
application is using the existing table which is maintain in the session. Means the burden to calling Database is reduced.
Can anybody help me how to maintain session scope as Application. Please give me a sample lines of code to solve this one.
All the one I need to write in the servlet only.

Thanks to all in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Moved to the Servlets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

While caching results is a common practice, I have no idea what you mean by "how to maintain session scope as Application".

There's session scope, and there's application scope.

You'd store user-specific information in the session scope, and data to be shared among all users in the application scope.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183


JDBCSupport - An easy to use, light-weight JDBC framework -
Murthy Tanniru
Greenhorn

Joined: Jun 03, 2008
Posts: 14
You can store the data in a cache. For this you can create a static class with static object.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

It is not necessary for cache classes to be static.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Your requirement is not clear. It seems like you are trying to grab user information for all the users whenever the firts user logs in, and then have this information available for all subsequent users that try to login. Please verify.

Also, as mentioned, session scope is different from application scope. Your application's needs will determine which is appropriate to use.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Setting the session scope as Application