I'm migrating an old app that uses application.cfm to use an application.cfc. The CFM sets a few globals such as
<cfset dsn = "myDSN">
I've tried putting that line of code in onApplicationStart, onRequestStart, etc. but trying to print that value out in a test page results in an error. Setting a value in the application scope (e.g. application.dsn) works fine of course but I'm under a tight deadline and can't rock the boat by doing a site-wide search and replace for each global.
I know putting these in scopes is the right thing to do but, for the time being, is there any way to switch to using Application.CFC but still create unscoped global variables?
Application event handlers are CFC methods that ColdFusion automatically executes when specific events occur during the lifetime of an application: application start and end, session start and end, request start, execution, and end, and exceptions.
ColdFusion always processes onRequestStart at the start of the request. If you implement an onRequest method, ColdFusion processes it; otherwise, it processes the requested page. If you implement an onRequest method, explicitly call the requested page in your onRequest method.
Try putting it inside onRequest()
instead of onRequestStart()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With