Very schematically this is how one of my systems worked (and still works with Application.cfm).
Let’s suppose we have two web sites web1.com and web2.com. Both use the same ColdFusion code but are very different.
Index.cfm (or any page) implicitly calls Application.cfm (a single one).
- Application.cfm looks at CGI.SCRIPT_NAME to find which one of the two sites called.
- Application.cfm queries a database common to all web sites and find the Application name associated with the caller. Ex: it find Application name = App1 for web1.com and sets AppName = “App1”
- Application.cfm executes a <CFAPPLICATION Name="#AppName#" . . .
- A single check on the existence of one Application variables (ex Application.Language) tells Application.cfm if this application just started or not.
- If the application just started (Application.Language was undefined) Appliocation.cfm runs a query on a database for this App1 application. The database contains pairs of (name,values) for all Application variables we want to set for App1. A simple loop then sets the 150 to 200 specific Applications variables we want for App1
That has worked like a charm since ColdFusion Allaire
That does not work with Application.cfc as let’s suppose a call was made by Web1.com. It starts (Wonderful, I thought my Application.cfm was working!) BUT BUT
As soon as Web2.com calls the stupid Application.cfc triggers on Application start , creates a new application with the name App2 and the environment of App1 which was running for Web1.com is gone! Now App2 runs but App1 is dead and as soon as Wedb1.com calls a page it restarts App1 (losing all the session and other App1 environment which was running before) and . . .kills App2!
I believe the problem is due to the fact that this stupid object structure makes Application.cfc part of the application it created when Application.cfm was “outside” the context of any application.
The only solution I found (after a few days of thinking, but maybe there is a better solution? Don’t hesitate to call me dumb if I missed something obvious) was to create a new “environment” folder for each application web1.com, web2.com, web3.com . . . and to duplicate Application.cfc and a few other necessary templates into each of those folders. For this to work, I created links into wwwroot to the folders for web1, web2, web3 . . .
This works but is very ugly and makes debugging and maintenance a nightmare.
Waht did I gain with Application.cfc? Nothing, Zilch, Niente, Rien du tout
O Yeah, the line OnApplication start did not exist and had to be replaced by a simple <CFIF IsDefined("Application.xxx Big deal! What an advantage for .cfc!
What did I lose: a lot, un sacco, beaucoup, mucho mucho
Thanks again to both of you for your precious help.