Setting Up the Web Application Framework
The first question you might be asking is, “Why do I need an application framework in the first place?” The answer is simple: the Web Application Framework allows you to group your CFML templates logically into a cohesive application or group of applications capable of maintaining state, utilizing constants, handling errors and exceptions, and enforcing security. Sound complicated? It really isn’t. As usual, ColdFusion abstracts the low-level programming that would normally be required to accomplish all of the tasks I just mentioned by providing two templates that serve as the foundation for the Web Application Framework. These templates, named Application.cfm and OnRequestEnd.cfm, are responsible for setting up and controlling every aspect of the Web Application Framework.
The Application.cfm File
In order to use the Web Application Framework, you have to create a template named Application.cfm, a special filename reserved by ColdFusion for use in the Web Application Framework. The initial Application.cfm template (there can be more than one) should be placed in the root directory of your ColdFusion application. Note that the filename is spelled with a capital “A”. This is especially important if you are running ColdFusion for Unix or Linux, where filenames are case sensitive.
When a CFML template is requested, ColdFusion checks to see whether there is an Application.cfm file in the same directory as the requested template. If so, the ...
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.