How to write a #objectNotFoundHandler

I need to write a little web app that runs a script on every request for a domain and returns something it gets from a database. This is how you do it.

1. Create a table, for example in the workspace table, at workspace.testsite.

2. Add two elements to it: #allowScriptsToRun with a value of true and a script called #objectNotFoundHandler.

3. Obviously point at the server running Frontier.

4. Set[“”] to be an address that points to workspace.testsite.

5. Now when any request comes in for, your objectNotFoundHandler script will run. So far so good.

6. To test this out I’d just have it return ( ()) and refresh the page a few times to assure yourself it is in fact getting the requests.

7. Now here’s the really big leap. You can’t call html.getpagetableaddress for some reason, but the parameters are available to the objectNotFoundHandler script as globals.

8. The key param is remainingPath which tells you what came after the domain in the request. So if the request is for, the value of remainingPath will be 2010/08/27/hiMom. That’s what you use to locate the object in the database.

I just wrote a little app at io.server.archiveWebsite that uses these principles. That will be released in a few days at most, so there’s a working example out there.


If you want to get the pagetable, and call code that can call html.getpagetableaddress (i.e. something that responds to a web request) you can do it.

local (pta);
html.setpagetableaddress (parentof (host));
pta = html.getpagetableaddress ()

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: