File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Setting the session scope as Application

 
ChakraPani Margani
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Servlets forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Murthy Tanniru
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not necessary for cache classes to be static.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic