Application events and the Application.cfc file.

In ColdFusion MX 7, Macromedia introduced application events and the Application.cfc file, which defines application settings and implements methods to handle the application events. Application events are specific occurrences during the life cycle of an application. Each time one of these events occurs, ColdFusion MX runs the corresponding method in your Application.cfc file (also referred to as the application CFC). You can implement application CFC methods to handle the following events:

.

Event

Trigger

Application start

ColdFusion starts processing the first request for a page in an application that is not running.

Application end

An application time-out setting is reached or the server shuts down.

Session start

A new session is created as a result of a request that is not in an existing session.

Session end

A session time-out setting is reached or, if using J2EE sessions, the user closes the browser.

Request start

ColdFusion receives a request, including HTTP requests, messages to the event gateway, SOAP requests, or Flash Remoting requests.

Request

Immediately after ColdFusion finishes processing the request start event. The handler for this event is intended for use as a filter for the request contents. For more information on the differences between request start and request events, see Managing requests in Application.cfc.

Request end

ColdFusion finishes processing all pages and CFCs for the request.

Exceptions

An exception occurs that is not handled in a try/catch block.

The Application.cfc file can also define application-wide settings, including the application name and whether the application supports Session variables.

For more information on using application events and the Application.cfc file, see Defining the application and its event handlers in Application.cfc.