|Frontier Tutorials / Writing an ObjectNotFoundHandler / ONFH Modes of Operation|
Your script can return information to mainResponder (and thus to the user) in several ways, as detailed below.
Render and/or return the page content, which mainResponder will insert into the template defined at the lastNomad point in your website.
Redirect to another URL, either inside your site or anywhere else on the internet.
Stuff data directly into the page table, and bypass remaining page rendering processing to avoid using the template.
As we'll see later, you can also use a mixture of these within the same website.
When it finds an objectNotFound entry in the page table, and that entry is a script or the address of a script, mainResponder.respond assumes that the script will return the page body text to be inserted in the template.
The script constructs and returns the entire body text for the page. This may include website framework calls to render data from elsewhere in the ODB--even from other websites or guest databases. It could even include calls outside of Frontier--to the file system or an SQL database, for example.
If flRender is TRUE, mainResponder.respond will insert whatever your script returns into the site template, as it does any normal page. If flRender is FALSE but allowScriptsToRun is TRUE, mainResponder.respond will return whatever your script returns as the complete page, without inserting it into the template.
A redirect is accomplished by calling mainResponder.redirect or by throwing a redirect scriptError (generally faster). For example, to redirect to http://yoursite/notfound404, you could do either of the following from your script:
Your script could either redirect to a fixed, hardcoded URL or calculate the new URL based on the values of lastNomad and remainingPath.
This is the simplest way for the ObjectNotFoundHandler script to work.
If you want to return something that should not be wrapped in the template and returned as an HTML page (such as binary objects or cascading stylesheet source files), you have to stuff the page table yourself. This is the most powerful approach available for ONFH handlers.
If you take this approach, you must set at least the following entries in the page table:
You may also want to set pageTbl^.responseHeaders.["Last-Modified"] (I generally do).