Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set an object in Application scope

 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I do not want to use caching mechanism, how can i access an object through the application life cycle?
I thought of adding an object in Application scope of web application but somehow not able to think from where should I start.
Please suggest how to add an object in Application scope.

I am using Tomcat 5.5 and my application is simple Servlet/JSP based (no Strust or Spring MVC etc)

~ abhay
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use ContextListeners for this.
Create your object and add it as a paramter to the context
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4419
252
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, have a look at ServletContext class, which has a setAttribute(-) method to add, and getAttribute() method to get an object to/from the application scope.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic