Intermittent Null Pointer error

I’m in the process of building a website for my wife’s new business. Sometimes when I browse to the website, I get the following error:

The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.

Null Pointers are another name for undefined values.

[snipped links to resources and user agent stuff]

java.lang.NullPointerException

It only happens occasionally, and usually when I’m checking the page in a new browser.

Any ideas as to what could be causing it?

The only unusual part of my setup is that I’ve called the page header and footer from Application.cfc, like so:

<cffunction
   name="OnRequest"
   access="public"
   returntype="void"
   output="true"
   hint="Fires after pre page processing is complete.">

<cfargument
   name="TargetPage"
   type="string"
   required="true" />

<cfinclude template="includes/header.cfm" />
<cfinclude template="#ARGUMENTS.TargetPage#" />
<cfinclude template="includes/footer.cfm" />

<cfreturn />
</cffunction>

Perhaps this could be causing problems?

A NullPointerException typically occurs in Java when you try to reference a nonexistent property of an object. Not sure what that means in CF terms. Wasn’t even aware CF used Java.

I’m willing to guess that you get the error when the TargetPage parameter is not set. Is there a way to set a default value for the parameter in CF? Something like this?

<cfargument
name=“TargetPage”
type=“string”
required=“true”
default=“index” />

Hmmm, that’s a good idea, and default is an acceptable attribute for <cfargument>. I think I’ll try that, thanks.

Now that I think about it, I have a bunch of default global attributes defined in my Application.cfc as well. I wonder if one of those isn’t getting set. Hmmm…