> I am new to ColdFusion and I am having trouble understanding what is the > Difference between onApplicationStart method and onRequestStart method other > than the Scope. For Example what does it mean by Application? First time a > user comes to your site? Does it only run once? I tried to set a Variable in > the onApplicationStart method like <cfset APPLICATION.ds="myDataSource"/> > and I get an Error when I say use it in index.cfm. Am i allowed to use this > outside in other files Or anything that gets set in onApplicationStart gets > passed to onApplicationEnd and thats where the variable get used? Thanks.
Hi Sherif, Welcome to the community. :) The onApplicationStart and onRequest start events are simply events which occur at a given time and aren't actually tied to any variable scopes, other than the fact that onApplicationStart executes immediately after the application scope is created. But you can do whatever you want to in that method. For example, you can create request variables in the onApplicationStart method, even though it executes before onRequestStart. So the lifespan of an application looks like this: 1. onApplicationStart 2. onSessionStart 3. onRequestStart 4. index.cfm 5. onRequestEnd 6. return to 3 (onRequestStart) and repeat 7. onSessionEnd - user timed out 8. return to 2 (onSessionStart) and repeat for other users 9. onApplicationEnd - application timed out 10. return to 1 (onApplicationStart) the next time the site is visited You can use application variables in index.cfm -- they need to be properly scoped, but if you set them in the onApplicationStart method they should be available. Your onApplicationStart method may not be executing if you haven't specified a name for your application. So your Application.cfc should look similar to this: <cfcomponent> <cfset this.name = "myapplication" /> <cffunction name="onApplicationStart" access="public"> <cfset application.ds = "myDataSource" /> </cffunction> .... </cfcomponent> You can also look to see what variables you have in your application scope from your index.cfm template by dumping the structure like this: <cfdump var="#application#" /> hth -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313193 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4