| Author |
how to set an object in Application scope
|
Abhay Agarwal
Ranch Hand
Joined: Feb 29, 2008
Posts: 716
|
|
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
|
Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
|
 |
Ashwin Sridhar
Ranch Hand
Joined: Jul 09, 2011
Posts: 272
|
|
You could use ContextListeners for this.
Create your object and add it as a paramter to the context
|
Ashwin Sridhar
SCJP | SCWCD | OCA
|
 |
Devaka Cooray
Saloon Keeper
Joined: Jul 29, 2008
Posts: 2729
|
|
|
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.
|
Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
HELP me! -- Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
|
 |
 |
|
|
subject: how to set an object in Application scope
|
|
|