|

Site
Visitors don't like to see ugly CF errors, even if they have
caused the errors themselves! Here's a Cold Fusion Power User
Tip!
A
common error occurrs when a user attempts to access a form
action page directly without having first submitted the form.
Cold Fusion generates error messages when the required form
values aren't present. Similar errors also occur when values
that don't exist in the underlying database are requested.
Eek!
A
good CF'er acommodates this scenario in their CF code. A common
way to do this is to wrap any CF form processing inside CFIF
tags - 'if these form values are present, process the form,
if not present a message to the visitor.'
Luckily
for the CF'er there's an way they can secure the site better,
and reduce errors that are visible to the site visitor, even
on pages that have slipped thru. The answer is <CFERROR>
and the Application.cfm file.
The
CFERROR tag tells Cold Fusion 'if there's an error of this
type, show this custom error page, and email the error to
the administrator'. It looks like this:
<CFERROR
TYPE="Request" (or Validation)
TEMPLATE="errorpage.cfm" MAILTO="youremail@foo.com">
Easy
enough, but what if you need to insert it on every page in
your site? Application.cfm to the rescue!
Every
time Cold Fusion processes a template (.cfm page) it first
looks for a file called Application.cfm - the Application
template, and processes it before the requested .cfm page.
To
'protect' all the pages in the site with CFERROR all you need
to do is add the CFERROR tag to the Application.cfm file -
How cool is that! Instant site wide controls via one file,
automatically 'added' to new pages... on the Club site for
example that's where we keep our Style Sheet along with other
stuff.
Cold
Fusion looks for an Application.cfm file first in the same
directory as the .cfm page that is being requested, if it's
not there it moves up the directory tree on the server looking
for one, if one doesn't exist it processes the requested page.
The
potential power of the Application.cfm file is enormous -
a great place to implement site wide security measures too!
If
you are interested in Cold Fusion we thoroughly recommend
Ben Forta's Cold Fusion Web Application Construction Kit ($39.99)
- it is THE Cold Fusion bible and very useful regardless of
what tool you are using to build your CF Applications.
You
can purchase the CF books from Amazon thru the Club by clicking
the book graphics above to help us keep these Cold Fusion
Workshops going.
[
to top of page ]
|