CFAPPLICATION Tag - ColdFusion


>> Return to CF Tag List

The CFAPPLICATION tag allows you define the scope of a ColdFusion "Application." Basically, this is a tag you use in an Application.cfm file. This file would be placed in the "root" directory of your web site. All pages in this directory and it's children would use the settings of this tag. That is of course, unless the CFAPPLICATION tag is used in a sub-directory. In which case that sub-directory and it's children would use the new CFAPPLICATION tag's new settings!

Syntax:
  <CFAPPLICATION
                      NAME="Application Name"
                      [CLIENTMANAGMENT="Yes/No"]
                      [CLIENTSTORAGE="Storage Method"]
                      [SETCLIENTCOOKIES="Yes/No"]
                      [SESSIONMANAGMENT="Yes/No"]
                      [SESSIONTIMEOUT="Time Span"]
                      [APPLICATIONTIMEOUT="Time Span"]
                      [SETDOMAINCOOKIES="Yes/No"]>

  CFAPPLICATION Comments from Adobe LiveDocsLiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
What is the impact of reducing the application timeout on existing variables in the application scope?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
Can we have a more detailed explanation of application timeout? Do all variables get timed out or only the oldest varaibles? How are variables aged? If the server has been running for 10 days and applications have a 20 minute timeout, do timeouts oocur every 20 minutes even though no variables have been created? That's say I have set my timeout to 20 minutes. If I add a variable to the application scope and 19 minutes later change it value, does this variable disappear 1 minute later?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
If ColdFusion is running on a cluster, you must specify clientStorage = "cookie" or a data source name; you cannot specify "registry".

Is it really possible that clientStorage can be specified as "cookie" when Coldfusion is running on a cluster?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
Undocumented behavior change. The 'Name' attribute no longer accepts non alpha numeric characters. It's essential to be aware of this if you use UUID's as your application names.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
On the Enterprise edition, you can do this through the Servlet API. CFDJ has an article on this, "Making the Most of J2EE Event Listeners" in the May 2004 Issue of CFDJ:
http://www.sys-con.com/magazine/?issueid=490&src=false

You may need a password to get past the link..

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
Is an event triggered when a session times out that can be trapped to allow CF to tidy up after the user?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
There are 2 question raised by this revised example:
1. does cfparam provide its own application scope and session scope locking?
2. by not using a cflock on the cfoutput, is it possible the output will be incorrect?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
We are working to improve the examples in the ColdFusion reference pages. We propose to replace the current example on this page with the the following example. If you have any comments on this example, add them to this page.

<!--- This example shows how to use cflock to prevent race conditions during data updates to variables in Application, Server, and Session scopes. --->
<h3>cfapplication Example</h3>
<p>cfapplication defines scoping for a ColdFusion application and enables or disables application and/or session variable storage. This tag is placed in a special file called Application.cfm that automatically runs before any other CF page in a directory (or subdirectory) where the Application.cfm file appears.</p>

<cfapplication name = "ETurtle"
sessionTimeout = #CreateTimeSpan(0, 0, 0, 60)#
sessionManagement = "Yes">

<!--- Initialize session and application variables used by E-Turtleneck. --->
<cfparam name="application.number" default="1">
<cfparam name="session.color" default= "">
<cfparam name="session.size" default="">

<cfif IsDefined("session.numPurchased") AND IsNumeric(trim(session.cartTotal))>
<!--- Use the application scope for the application variable to prevent race condition. This variablekeeps track of total number of turtlenecks sold. --->
<cflock scope = "Application" timeout = "30" type = "Exclusive">
<cfset application.number = application.number + session.numPurchased>
</cflock>
</cfif>

<cfoutput>
E-Turtleneck is proud to say that we have sold #application.number# turtlenecks to date.
</cfoutput>
<!--- End of Application.cfm --->

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
Modify the scope locking text to indicate that with CFMX scope locking is only necessary to prevent race conditions. See http://www.macromedia.com/support/coldfusion/ts/documents/tn18235.htm.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
Add to the description for the Name attribute, the fact that there can only be 1 unnamed application. And that if there are more than 1, then they all share the same application scope.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
ColdFusion MX does not require an Application name to use Application scope variables.
However, there can only be one unnamed Application on a ColdFusion J2EE application.
For more information see http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/java18.htm

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa3.htm
See http://www.macromedia.com/support/coldfusion/ts/documents/hotfix_domain_cookies.htm for information on fixing a problem with cfapplication and domain cookies.



[Top]


Recommended Books

[Top]

Web Sites

[Top]

Copyright © 2003- 2008, Orville Paul Chomer, All Rights Reserved