The term application can mean many things. An application can be as simple as a guest book or as sophisticated as a full Internet commerce system with catalog pages, shopping carts, and reporting.
An application, however, has a specific meaning in ColdFusion. A ColdFusion application has the following characteristics:
- It consists of one or more ColdFusion pages that work together and share a common set of resources.
- All pages in the application share an application name and configuration settings as specified in an Application.cfc file or a cfapplication tag.
- All pages in the application share variables in the Application scope.
- You can write application-wide event handlers for specific events, such as request start or session end.
What appears to a user to be a single application (for example, a company's website), can consist of multiple ColdFusion applications.
ColdFusion applications are not J2EE applications. However, if you do not specify an application name in your Application.cfc file or cfapplication tag, the Application scope corresponds to the J2EE application servlet context.
ColdFusion applications end when the application has been inactive for the application time-out period or the server stops. When the application times out, ColdFusion releases all Application scope variables. You must, therefore, select a time-out period that balances the need for clearing Application scope memory and the overhead of re-creating the scope. A typical application time-out is two days.
ColdFusion applications and sessions are independent of each other. For example, if an application times out while a user's session is active, the session continues and the session context, including the user's Session scope variables, is unaffected by the application ending and restarting.
Although, there are no definite rules about how you represent your web application as a ColdFusion application or applications, the following guidelines are useful:
- Application pages share a common general purpose. For example, a web storefront is typically a single ColdFusion application.
- Many, but not necessarily all, pages in a ColdFusion application share data or common code elements, such as a single login mechanism.
- Application pages share a common look-and-feel, often enforced by using common code elements, such as the same header and footer pages, and a common error message template.