The Application.cfc is a component you put in your web application that then is picked up by Lucee as part of the request. The Application.cfc is used to define context specific configurations/settings and event driven functions. Your website can have multiple Application.cfc files, every single file then defines a independent application context.
Let's say you have a website that has a shop under the path "/shop" that needs users sessions, but the rest of the website does not. In that case you could define a Application.cfc at "/shop" that has session handling enabled and one in the webroot that has not.
With the default setting Lucee is always picking the "nearest" Application.cfc, so it is searching from the current location down to the webroot. This is only one possible behavior of many, Lucee gives you the possibility in the Lucee Administartor under "Settings / Request" to decide where Lucee looks for the Application.cfc and if it looks at all.
So if you for example only have one Application.cfc in the webroot, define "Root" as setting.
The Application.cfc is supporting multiple event driven functions, what does this means? You can define functions inside the Application.cfc that are called when certain events are happening, this way you can participate with this events.
This is normally used to initialize the environment for your application, so for example load data/objects and store them in the application scope. if the the function is returning false or throws a exception the application context is not initialized and the next request will call "onApplicationStart" again. "onApplicationStart" is thread safe.
This function is triggered with every request that has no session definedin the current application context
This is normally used to initialize the environment for a specific session, so for example load data/objects and store them in the session scope.
The opposite from "onSessionStart", this function is triggered when a specific session context ends, means when the timeout of a session context is reached (this.sessionTimeout).
This is normally used to finalize the environment of your application, so for example unload data/objects. You get the related application scope and the session scope that ends, as arguments with the function.
This function is triggered before every request, so you can prepare the environment for the request, for example produce the HTML header or loads some data/objects used within the request.
if the the function is returning false Lucee stops any further execution of this request and return the result to the client.
This function is triggered after every request, so you can cleanup the environment after the request, for example produce the HTML footer or unload some data/objects used within the request.
If this function exists, Lucee is only executing this function and no longer looks for the "targetPage" defined with the request. So let's say you have the call "/index.cfm", if there is a "/index.cfm" in the file system or not, does not matter, it is not executed anyway.
Other CFML Engines will complain when the called target page does not exists physically even it is never used!
Similar to "onRequest", but this function is used to handle remote component calls (HTTP Webservices).
This method is triggered when a uncaught exception occurs in this application context.
As arguments you get the exception (cfcatch block) and the eventName.
This method is triggered when a request is ended with help of the tag
This method is triggered when debugging is enabled for this request.
This method is triggered when a requested page was not found and no function "onRequest" is defined .