Accessing Any Application Scope
ColdFusion
Recently we encountered a challenge where a sub-application (having its own ApplicationName) was going to require accessing information stored in its parent's Application scope. What we found were two feasible methods for accessing the necessary info.
- Accessing the Java object ApplicationScopeTracker
- Instantiate the java object
- <cfset variableName = createObject("java","coldfusion.runtime.ApplicationScopeTracker")>
- Dumping variableName will show you these available methods:
cleanUp (returns void)
getApplicationScope (returns coldfusion.runtime.ApplicationScope)
createApplication (returns coldfusion.runtime.ApplicationScope)
forceCleanUp (returns void)
getApplicationKeys (returns interface java.util.Enumeration)
hashCode (returns int)
getClass (returns java.lang.Class)
wait (returns void)
equals (returns boolean)
notify (returns void)
notifyAll (returns void)
toString (returns java.lang.String)- You can use the getApplicationScopeKeys() to return an iterator of available ApplicationNames
- A simple way to view the app names would be to do something like:
<cfset appIterator = variableName .getApplicationKeys() />
<cfloop condition=#appIterator.hasMoreElements()# >
<cfoutput>#appIterator.nextElement()#</cfoutput> >
</cfloop>- Once you have the ApplicationName you want you can simply call that applications scope using:
variableName.getApplicationScope("that application's name")
- Another way is to view ALL applications on a given server, and everything that each scope has a handle on is by doing this:
<cfapplication = "">
<cfdump var=#application#>- This will show you a structure of pretty much anything you could ever want to access. This should serve as a lesson to those people storing sensitive data in the Application scope on shared servers.




Loading....