Create an Application.cfc

Application.cfc

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 an independent application context.

Let's say you have a website that has a shop under the path "/shop" that needs user sessions, but the rest of the website does not. In that case you could define an Application.cfc at "/shop" that has session handling enabled and one in the webroot that has not.

Location, Location, Location

With the default setting Lucee always picks the "nearest" Application.cfc, so it searches from the current location down to the webroot. This is only one possible behavior of many, Lucee gives you the possibility in the Lucee Administrator under "Settings / Request" to decide where Lucee looks for the Application.cfc and if it looks at all.

search mode

So, for example, if you only have one Application.cfc in the webroot, define "Root" as setting.

Functions

The Application.cfc supports multiple event driven functions, what does this mean? You can define functions inside the Application.cfc that are called when certain events happen.

OnApplicationStart

This function is triggered when no application context exists for this Application.cfc, so normally when the first request on this application context is made.

component {
   boolean function onApplicationStart() {
      application.whatever=new Whatever(); // init whatever
   }
}

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 function returns false or throws an exception, the application context is not initialized and the next request will call "onApplicationStart" again. "onApplicationStart" is thread safe.

OnApplicationEnd

The opposite from "onApplicationStart", this function is triggered when the application context ends, means when the timeout of the application context is reached (this.applicationTimeout).

component {
   void function onApplicationEnd(struct application) {
      arguments.application.whatever.finalize();
   }
}

This is normally used to finalize the environment of your application, so for example unload data/objects. You receive the application scope that ends as an argument to the function.

OnSessionStart

This function is triggered with every request that has no session defined in the current application context.

component {
   void function onSessionStart() {
      session.whatever=new Whatever(session.cfid); // init whatever
   }
}

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.

OnSessionEnd

The opposite from "onSessionStart", this function is triggered when a specific session context ends, when the timeout of a session context is reached (this.sessionTimeout).

Irrespective of the exact sessionTimeout value, onSessionEnd is called when the background controller thread cleans up expired scopes (i.e. session, application), by default, this process runs every minute.

component {
   void function onSessionEnd(struct session,struct application) {
      arguments.session.whatever.finalize();
   }
}

This is normally used to finalize the environment of your application, so for example unload data/objects. You receive the related application scope and the session scope that ends, as arguments to the function.

OnRequestStart

This function is triggered before every request, so you can prepare the environment for the request, for example to produce the HTML header or load some data/objects used within the request.

component {
   boolean function onRequestStart(string targetPage) {
       echo('<html><head><body>'); // outputs the response HTML header
       request.whatever=new Whatever(); // prepare an object to use within the request
       return true;
   }
}

If the function returns false, Lucee stops any further execution of this request and return the result to the client.

OnRequestEnd

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.

component {
   void function onRequestEnd(string targetPage) {
       echo('</body></html>'); // outputs the response HTML footer
       request.whatever.finalize();
   }
}

OnRequest

If this function exists, Lucee only executes 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 an "/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 exist physically even it is never used!

component {
   void function onRequest(string targetPage) {
       echo('<html><body>Hello World</body></html>');
   }
}

OnCFCRequest

Similar to "onRequest", but this function is used to handle remote component calls (HTTP Webservices).

component {
   void function onCFCRequest(string cfcName, string methodName, struct args) {
       echo('<html><body>Hello World</body></html>');
   }
}

OnError

This method is triggered when an uncaught exception occurs in this application context.

component {
   void function onError(struct exception, string eventName) {
       dump(var:exception,label:eventName);
   }
}

As arguments you receive the exception (cfcatch block) and the eventName.

OnAbort

This method is triggered when a request is ended with help of the tag .

component {
   void function onAbort(string targetPage) {
       dump("request "&targetPage&" ended with an abort!");
   }
}

OnDebug

This method is triggered when debugging is enabled for this request.

component {
   void function onDebug(struct debuggingData) {
       dump(var:debuggingData,label:"debug information");
   }
}

OnMissingTemplate

This method is triggered when a requested page was not found and **no function "onRequest" is defined **.

component {
   void function onMissingTemplate(string targetPage) {
       echo("missing:"&targetPage);
   }
}

Application.cfc Default Template

Below you can find an Application.cfc template that may serve as a starting point for your own applications settings with Lucee CFML engine.

When creating an Application.cfc for the first time, you can configure all the settings within the Lucee Server or Web Administrator and use its "Export" tool ( Lucee Adminisitrator => Settings => Export ) to move (by copy and paste) the settings to your Application.cfc.

component displayname="Application" output="false" hint="Handle the application" {
<span class="o">/***************************************************************************</span>
<span class="o">*</span> <span class="nv">INTRODUCTION</span>
<span class="o">****************************************************************************</span>
<span class="o">*</span>  <span class="nv">This</span> <span class="nv">Application.cfc</span> <span class="nv">template</span> <span class="nv">should</span> <span class="nv">serve</span> <span class="nv">as</span> <span class="nv">a</span> 
<span class="o">*</span>  <span class="nv">starting</span> <span class="nv">point</span> <span class="nv">for</span> <span class="nv">your</span> <span class="nv">applications</span> <span class="nv">settings</span> <span class="nv">running</span>
<span class="o">*</span>  <span class="nv">with</span> <span class="nv">Lucee</span> <span class="nv">CFML</span> <span class="nv">engine.</span> 
<span class="o">*</span> 
<span class="o">*</span>  <span class="nv">The</span> <span class="nv">settings</span><span class="o">/</span><span class="nv">definitions</span> <span class="nv">are</span> <span class="nv">set</span> <span class="nv">as</span> <span class="nv">comments</span> <span class="o">and</span> <span class="nv">represent</span> <span class="nv">Lucees</span> <span class="k">default</span>
<span class="o">*</span>  <span class="nv">settings.</span> <span class="nv">Some</span> <span class="nv">settings</span><span class="o">/</span><span class="nv">definitions</span> <span class="nv">should</span> <span class="nv">only</span> <span class="nv">serve</span> <span class="nv">as</span> <span class="nv">helping</span> 
<span class="o">*</span>  <span class="nv">examples</span><span class="p">,</span> <span class="nv">e.g.</span> <span class="nv">datasources</span><span class="p">,</span> <span class="nv">mailservers</span><span class="p">,</span> <span class="nv">cache</span><span class="p">,</span> <span class="nv">mappings</span>
<span class="o">*</span>
<span class="o">*</span>  <span class="nv">When</span> <span class="nv">creating</span> <span class="nv">an</span> <span class="nv">Application.cfc</span> <span class="nv">for</span> <span class="nv">the</span> <span class="nv">first</span> <span class="nv">time</span><span class="p">,</span> <span class="nv">you</span> <span class="nv">can</span> <span class="nv">configure</span> 
<span class="o">*</span>  <span class="nv">all</span> <span class="nv">the</span> <span class="nv">settings</span> <span class="nv">within</span> <span class="nv">the</span> <span class="nv">Lucee</span> <span class="nv">Server</span> <span class="o">or</span> <span class="nv">Web</span> <span class="nv">Administrator</span> 
<span class="o">*</span>  <span class="o">and</span> <span class="nv">use</span> <span class="nv">its</span> <span class="s2">&quot;Export&quot;</span> <span class="nf">tool</span> <span class="p">(</span> <span class="nv">Lucee</span> <span class="nv">Adminisitrator</span> <span class="o">=&gt;</span> <span class="nv">Settings</span> <span class="o">=&gt;</span> <span class="nv">Export</span> <span class="p">)</span>  
<span class="o">*</span>  <span class="nv">to</span> <span class="nf">move</span> <span class="p">(</span><span class="nv">by</span> <span class="nv">copy</span> <span class="o">and</span> <span class="nv">paste</span><span class="p">)</span> <span class="nv">the</span> <span class="nv">settings</span> <span class="nv">to</span> <span class="nv">your</span> <span class="nv">Application.cfc.</span>
<span class="o">*</span> 
<span class="o">*</span>  <span class="nv">For</span> <span class="nv">further</span> <span class="nv">reference</span> <span class="nv">please</span> <span class="nv">see</span> <span class="nv">the</span> <span class="nv">following</span> <span class="nv">documentation</span> <span class="nv">at</span><span class="p">:</span>
<span class="o">*</span>  <span class="nv">https</span><span class="p">:</span><span class="c">//docs.lucee.org/categories/application.html</span>
<span class="o">*</span>  <span class="nv">https</span><span class="p">:</span><span class="c">//docs.lucee.org/guides/cookbooks/application-context-basic.html</span>
<span class="o">*</span>  <span class="nv">https</span><span class="p">:</span><span class="c">//docs.lucee.org/reference/tags/application.html</span>
<span class="o">*</span>  <span class="nv">https</span><span class="p">:</span><span class="c">//docs.lucee.org/guides/Various/system-properties.html</span>
<span class="o">*</span> 
<span class="o">***************************************************************************/</span>

//////////////////////////////////////////////////////////////// // APPLICATION NAME // Defines the name of your application //////////////////////////////////////////////////////////////// // this.name = "myApplication";

//////////////////////////////////////////////////////////////// // LOCALE // Defines the desired time locale for the application //////////////////////////////////////////////////////////////// // this.locale = "en_US";

//////////////////////////////////////////////////////////////// // TIME ZONE // Defines the desired time zone for the application //////////////////////////////////////////////////////////////// // this.timezone = "Europe/Berlin";

//////////////////////////////////////////////////////////////// // WEB CHARSET // Default character set for output streams, form-, url-, and // cgi scope variables and reading/writing the header //////////////////////////////////////////////////////////////// // this.charset.web="UTF-8";

//////////////////////////////////////////////////////////////// // RESOURCE CHARSET // Default character set for reading from/writing to // various resources //////////////////////////////////////////////////////////////// // this.charset.resource="windows-1252";

//////////////////////////////////////////////////////////////// // APPLICATION TIMEOUT // Sets the amount of time Lucee will keep the application scope alive. //////////////////////////////////////////////////////////////// // this.applicationTimeout = createTimeSpan( 1, 0, 0, 0 );

//////////////////////////////////////////////////////////////// // SESSION TYPE // Defines the session engine // - Application: Default cfml sessions // - JEE: JEE Sessions allow to make sessions over a cluster. //////////////////////////////////////////////////////////////// // this.sessionType = "application";

//////////////////////////////////////////////////////////////// // SESSION MANAGEMENT // Enables/disables session management //////////////////////////////////////////////////////////////// // this.sessionManagement = true;

//////////////////////////////////////////////////////////////// // SESSION TIMEOUT // Sets the amount of time Lucee will keep the session scope alive. //////////////////////////////////////////////////////////////// // this.sessionTimeout = createTimeSpan( 0, 0, 30, 0 );

//////////////////////////////////////////////////////////////// // SESSION STORAGE // Default Storage for Session, possible values are: // - memory: the data are only in the memory, so in fact no persistent storage // - file: the data are stored in the local filesystem // - cookie: the data are stored in the users cookie // - <cache-name>: name of a cache instance that has "Storage" enabled // - <datasource-name>: name of a datasource instance that has "Storage" enabled //////////////////////////////////////////////////////////////// // this.sessionStorage = "memory";

//////////////////////////////////////////////////////////////// // CLIENT MANAGEMENT // Enables/disables client management //////////////////////////////////////////////////////////////// // this.clientManagement = false;

//////////////////////////////////////////////////////////////// // CLIENT COOKIES // Enables/disables client cookies //////////////////////////////////////////////////////////////// // this.setClientCookies = true;

//////////////////////////////////////////////////////////////// // CLIENT TIMEOUT // Sets the amount of time Lucee will keep the client scope alive. //////////////////////////////////////////////////////////////// // this.clientTimeout = createTimeSpan( 90, 0, 0, 0 );

//////////////////////////////////////////////////////////////// // CLIENT STORAGE // Default Storage for Session, possible values are: // - memory: the data are only in the memory, so in fact no persistent storage // - file: the data are stored in the local filesystem // - cookie: the data are stored in the users cookie // - <cache-name>: name of a cache instance that has "Storage" enabled // - <datasource-name>: name of a datasource instance that has "Storage" enabled //////////////////////////////////////////////////////////////// // this.clientStorage = "cookie";

//////////////////////////////////////////////////////////////// // DOMAIN COOKIES // Enables or disables domain cookies. //////////////////////////////////////////////////////////////// // this.setDomainCookies = false;

//////////////////////////////////////////////////////////////// // CGI READ ONLY // Defines whether the CGI Scope is read only or not. //////////////////////////////////////////////////////////////// // this.cgiReadOnly = true;

//////////////////////////////////////////////////////////////// // LOCAL SCOPE MODE // Defines how the local scope of a function is invoked when a variable with no scope definition is used. // - modern: the local scope is always invoked // - classic: CFML default, the local scope is only invoked when the key already exists in it //////////////////////////////////////////////////////////////// // this.localMode = "classic";

//////////////////////////////////////////////////////////////// // CASCADING // Depending on this setting Lucee scans certain scopes to find a // variable called from the CFML source. This will only happen when the // variable is called without a scope. (Example: #myVar# instead of #variables.myVar#) // - strict: scans only the variables scope // - small: scans the scopes variables,url,form // - standard: CFML Standard, scans the scopes variables,cgi,url,form,cookie //////////////////////////////////////////////////////////////// // this.scopeCascading = "standard";

//////////////////////////////////////////////////////////////// // SEARCH RESULTSETS // When a variable has no scope defined (Example: #myVar# instead of #variables.myVar#), // Lucee will also search available resultsets (CFML Standard) or not //////////////////////////////////////////////////////////////// // this.searchResults = true;

//////////////////////////////////////////////////////////////// // REQUEST: TIMEOUT // Sets the amount of time the engine will wait // for a request to finish before a request timeout will // be raised. This means that the execution of the request // will be stopped. This setting can be overridden using the // "cfsetting" tag or script equivalent. //////////////////////////////////////////////////////////////// // this.requestTimeout=createTimeSpan(0,0,0,50);

//////////////////////////////////////////////////////////////// // COMPRESSION // Enable compression (GZip) for the Lucee Response stream // for text-based responses when supported by the client (Web Browser) //////////////////////////////////////////////////////////////// // this.compression = false;

//////////////////////////////////////////////////////////////// // SUPPRESS CONTENT FOR CFC REMOTING // Suppress content written to response stream when a // Component is invoked remote //////////////////////////////////////////////////////////////// // this.suppressRemoteComponentContent = false;

//////////////////////////////////////////////////////////////// // BUFFER TAG BODY OUTPUT // If true - the output written to the body of the tag is // buffered and is also outputted in case of an exception. Otherwise // the content to body is ignored and not displayed when a failure // occurs in the body of the tag. //////////////////////////////////////////////////////////////// // this.bufferOutput = false;

//////////////////////////////////////////////////////////////// // UDF TYPE CHECKING // Enables/disables type checking of definitions with // function arguments and return values //////////////////////////////////////////////////////////////// // this.typeChecking = true;

//////////////////////////////////////////////////////////////// // QUERY CHACHEDAFTER // Global caching lifespan for queries. This value is overridden when // a tag "query" has the attribute "cachedwithin" defined. //////////////////////////////////////////////////////////////// // this.query.cachedAfter = createTimeSpan(0,0,0,0);

//////////////////////////////////////////////////////////////// // REGEX // Defines the regular expression dialect to be used. // - modern: Modern type is the dialect used by Java itself. // - classic CFML default, the classic CFML traditional type Perl5 dialect //////////////////////////////////////////////////////////////// // this.regex.type = "perl";

//////////////////////////////////////////////////////////////// // IMPLICIT NOTATION // If there is no accessible data member (property, element of the this scope) // inside a component, Lucee searches for available matching "getters" or // "setters" for the requested property. The following example should // clarify this behaviour. "somevar = myComponent.properyName". // If "myComponent" has no accessible data member named "propertyName", // Lucee searches for a function member (method) named "getPropertyName". //////////////////////////////////////////////////////////////// // this.invokeImplicitAccessor = false;

//////////////////////////////////////////////////////////////// // ANTI-XXE CONFIGURATION // XML External Entity attack is a type of attack against // an application that parses XML input. This configuration enable/disable // protection by XXE attack. It's enabled by default from 5.4.2 and 6.0. // https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing //////////////////////////////////////////////////////////////// // this.xmlFeatures = { // externalGeneralEntities: false, // secure: true, // disallowDoctypeDecl: false // };

//////////////////////////////////////////////////////////////// // MAIL SERVERS // defines one or more mail server connections. // When sending an email, Lucee tries to send the mail with the first // defined mail server. If the send operation fails, Lucee will // continue using the next mail server in the list. //////////////////////////////////////////////////////////////// // this.mailservers =[ // { // host: "smtp.somesmtp.org" // ,port: 587 // ,username: "email@somedomain.org" // ,password: "mypassword" // ,ssl: false // ,tls: true // ,lifeTimespan: CreateTimeSpan( 0, 0, 1, 0 ) // ,idleTimespan: CreateTimeSpan( 0, 0, 0, 10 ) // } // ];

//////////////////////////////////////////////////////////////// // DATASOURCES // Defines datasources by datasource name. These can be addressed by // by the "datasource" attribute of a "query" tag. //////////////////////////////////////////////////////////////// // // this.datasources["myDsnName"] = { // class: 'com.mysql.cj.jdbc.Driver' // , bundleName: 'com.mysql.cj' // , bundleVersion: '8.0.19' // , connectionString: 'jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=Europe/Berlin&maxReconnects=3' // , username: 'root' // , password: "encrypted:..."

// // optional settings // , connectionLimit:100 // default:-1 // , liveTimeout:60 // default: -1; unit: minutes // , alwaysSetTimeout:true // default: false // , validate:false // default: false // };

//////////////////////////////////////////////////////////////// // CACHES //////////////////////////////////////////////////////////////// // this.cache.connections["myCache"] = { // class: 'lucee.runtime.cache.ram.RamCache' // , storage: false // , custom: {"timeToIdleSeconds":"0","timeToLiveSeconds":"0"} // , default: '' // };

//////////////////////////////////////////////////////////////// // MAPPINGS //////////////////////////////////////////////////////////////// // // this.mappings["/lucee/admin"]={ // physical:"{lucee-config}/context/admin" // ,archive:"{lucee-config}/context/lucee-admin.lar" // }; // // this.mappings["/lucee/doc"]={ // archive:"{lucee-config}/context/lucee-doc.lar" // };

<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nv">First</span> <span class="nv">function</span> <span class="nv">run</span> <span class="nv">when</span> <span class="nv">Lucee</span> <span class="nv">receives</span> <span class="nv">the</span> <span class="nv">first</span> <span class="nv">request.</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">boolean</span> <span class="nv">function</span> <span class="nf">OnApplicationStart</span><span class="p">(){</span>
    <span class="nv">return</span> <span class="nv">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onApplicationEnd</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">when</span> <span class="nv">the</span> <span class="nv">application</span> <span class="nv">context</span> <span class="nv">ends</span><span class="p">,</span> <span class="nv">means</span> <span class="nv">when</span> <span class="nv">the</span> 
<span class="o">*</span> <span class="nv">timeout</span> <span class="nv">of</span> <span class="nv">the</span> <span class="nv">application</span> <span class="nv">context</span> <span class="o">is</span> <span class="nf">reached</span> <span class="p">(</span><span class="nv">this.applicationTimeout</span><span class="p">).</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onApplicationEnd</span><span class="p">(</span> <span class="nv">struct</span> <span class="nv">application</span> <span class="p">){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onSessionStart</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">with</span> <span class="nv">every</span> <span class="nv">request</span> <span class="nv">that</span> <span class="nv">has</span> <span class="nv">no</span> <span class="nv">session</span> 
<span class="o">*</span> <span class="nv">defined</span> <span class="nv">in</span> <span class="nv">the</span> <span class="nv">current</span> <span class="nv">application</span> <span class="nv">context.</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onSessionStart</span><span class="p">(){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onSessionEnd</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">when</span> <span class="nv">a</span> <span class="nv">specific</span> <span class="nv">session</span> <span class="nv">context</span> <span class="nv">ends</span><span class="p">,</span> 
<span class="o">*</span> <span class="nv">when</span> <span class="nv">the</span> <span class="nv">timeout</span> <span class="nv">of</span> <span class="nv">a</span> <span class="nv">session</span> <span class="nv">context</span> <span class="o">is</span> <span class="nf">reached</span> <span class="p">(</span><span class="nv">this.sessionTimeout</span><span class="p">).</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onSessionEnd</span><span class="p">(</span> <span class="nv">struct</span> <span class="nv">session</span><span class="p">,</span> <span class="nv">struct</span> <span class="nv">application</span> <span class="p">){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onRequestStart</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">before</span> <span class="nv">every</span> <span class="nv">request</span><span class="p">,</span> <span class="nv">so</span> <span class="nv">you</span> <span class="nv">can</span> 
<span class="o">*</span> <span class="nv">prepare</span> <span class="nv">the</span> <span class="nv">environment</span> <span class="nv">for</span> <span class="nv">the</span> <span class="nv">request</span><span class="p">,</span> <span class="nv">for</span> <span class="nv">example</span> <span class="nv">to</span> <span class="nv">produce</span> <span class="nv">the</span> <span class="nv">HTML</span> 
<span class="o">*</span> <span class="nv">header</span> <span class="o">or</span> <span class="nv">load</span> <span class="nv">some</span> <span class="nv">data</span><span class="o">/</span><span class="nv">objects</span> <span class="nv">used</span> <span class="nv">within</span> <span class="nv">the</span> <span class="nv">request.</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">boolean</span> <span class="nv">function</span> <span class="nf">onRequestStart</span><span class="p">(</span> <span class="nv">string</span> <span class="nv">targetPage</span> <span class="p">){</span>
    <span class="nv">return</span> <span class="nv">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onRequest</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">during</span> <span class="nv">a</span> <span class="nv">request</span> <span class="nv">right</span> <span class="nv">after</span> <span class="nf">onRequestStart</span><span class="p">()</span> <span class="nv">ends</span> <span class="o">and</span> <span class="nv">before</span> 
<span class="o">*</span> <span class="nf">onRequestEnd</span><span class="p">()</span> <span class="nv">starts.</span> <span class="nv">Unlike</span> <span class="nv">other</span> <span class="nv">CFML</span> <span class="nv">engines</span><span class="p">,</span> <span class="nv">Lucee</span> <span class="nv">executes</span> <span class="nv">this</span> <span class="nv">function</span> <span class="nv">without</span> <span class="nv">looking</span> 
<span class="o">*</span> <span class="nv">for</span> <span class="nv">the</span> <span class="s2">&quot;targetPage&quot;</span> <span class="nv">defined</span><span class="p">,</span> <span class="nv">while</span> <span class="nv">other</span> <span class="nv">CFML</span> <span class="nv">engines</span> <span class="nv">will</span> <span class="nv">complain</span> <span class="k">if</span> <span class="nv">the</span> <span class="nv">targetPage</span> <span class="nv">doesn</span><span class="err">&#39;</span><span class="nv">t</span> 
<span class="o">*</span> <span class="nv">physically</span> <span class="nf">exist</span> <span class="p">(</span><span class="nv">even</span> <span class="k">if</span> <span class="o">not</span> <span class="nv">used</span> <span class="nv">in</span> <span class="nv">the</span> <span class="nf">onRequest</span><span class="p">()</span> <span class="nv">function</span><span class="p">)</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onRequest</span><span class="p">(</span> <span class="nv">string</span> <span class="nv">targetPage</span> <span class="p">){</span>
    <span class="nv">include</span> <span class="nv">arguments.targetPage</span><span class="p">;</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onRequest</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">at</span> <span class="nv">the</span> <span class="nv">end</span> <span class="nv">of</span> <span class="nv">a</span> <span class="nv">request</span><span class="p">,</span> <span class="nv">right</span> <span class="nv">after</span> <span class="nf">onRequest</span><span class="p">()</span> <span class="nv">finishes.</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onRequestEnd</span><span class="p">(){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onCFCRequest</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">during</span> <span class="nv">a</span> <span class="nv">request</span> <span class="nv">for</span> <span class="nv">a</span> <span class="p">.</span><span class="nv">cfc</span> <span class="nv">component</span><span class="p">,</span> <span class="nv">typically</span>
<span class="o">*</span> <span class="nv">used</span> <span class="nv">to</span> <span class="nv">handle</span> <span class="nv">remote</span> <span class="nv">component</span> <span class="nf">calls</span> <span class="p">(</span><span class="nv">e.g.</span> <span class="nv">HTTP</span> <span class="nv">Webservices</span><span class="p">).</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onCFCRequest</span><span class="p">(</span> <span class="nv">string</span> <span class="nv">cfcName</span><span class="p">,</span> <span class="nv">string</span> <span class="nv">methodName</span><span class="p">,</span> <span class="nv">struct</span> <span class="nv">args</span> <span class="p">){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onError</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">when</span> <span class="nv">an</span> <span class="nv">uncaught</span> <span class="nv">exception</span> <span class="nv">occurs</span> <span class="nv">in</span> <span class="nv">this</span> <span class="nv">application</span> <span class="nv">context.</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onError</span><span class="p">(</span> <span class="nv">struct</span> <span class="nv">exception</span><span class="p">,</span> <span class="nv">string</span> <span class="nv">eventname</span> <span class="p">){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">OnAbort</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">when</span> <span class="nv">a</span> <span class="nv">request</span> <span class="o">is</span> <span class="nv">ended</span> <span class="nv">with</span> <span class="nv">help</span> <span class="nv">of</span> <span class="nv">the</span> <span class="s2">&quot;abort&quot;</span> <span class="nv">tag.</span> 
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span>  <span class="nf">onAbort</span><span class="p">(</span> <span class="nv">string</span> <span class="nv">targetPage</span> <span class="p">){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onDebug</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">when</span> <span class="nv">debugging</span> <span class="o">is</span> <span class="nv">enabled</span> <span class="nv">for</span> <span class="nv">this</span> <span class="nv">request.</span>
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onDebug</span><span class="p">(</span> <span class="nv">struct</span> <span class="nv">debuggingData</span> <span class="p">){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="o">/**</span>
<span class="o">*</span> <span class="err">@</span><span class="nv">hint</span> <span class="nf">onMissingTemplate</span><span class="p">()</span> <span class="o">is</span> <span class="nv">triggered</span> <span class="nv">when</span> <span class="nv">the</span> <span class="nv">requested</span> <span class="nv">page</span> <span class="nv">wasn</span><span class="err">&#39;</span><span class="nv">t</span> <span class="nv">found</span> <span class="o">and</span> <span class="nv">no</span> <span class="s2">&quot;onRequest()&quot;</span> 
<span class="o">*</span> <span class="nv">function</span> <span class="o">is</span> <span class="nv">defined.</span>
<span class="o">*/</span>
<span class="nv">public</span> <span class="nv">void</span> <span class="nv">function</span> <span class="nf">onMissingTemplate</span><span class="p">(</span> <span class="nv">string</span> <span class="nv">targetPage</span> <span class="p">){</span>
    <span class="nv">return</span><span class="p">;</span>
<span class="p">}</span>

}

See also