Application Direct URLs | |
06:34 AM Learn | Basic Setup | Templates | Server Security | Direct URLs | URL Domains
An application direct URL provides a direct mapping from a URL to a Tcl procedure defined inside the server. The /hello URL is an example. Look at the custom/hello.tcl to see how it is implemented.
The first step in creating application direct URLs is to define a mapping from a URL prefix (e.g., /hello) to a Tcl command prefix (e.g., ::hello::).
Direct_Url /hello ::hello::Now, define a Tcl procedure who's name starts with ::hello:: (this puts it into the ::hello namespace).
namespace eval ::hello { # ensure ::hello namespace exists } proc ::hello::/world {} { return "Hello, World!" }This defines an implementation of the /hello/world URL that will print a simple message in the user's browser.
The correspondence between the URL and Tcl procedure name is
made with an exact substitution of /hello with
::hello::. Only if that Tcl procedure exists will
a page be returned, otherwise you get a 404 Not Found error.
Suppose you have this simple form:
<form action=/hello/formhandler method=POST>
<input type=text name=foo>
<input type=submit>
</form>
You can define a form handler like this:
proc ::hello::/formhandler {foo} {
return "You entered foo=$foo"
}
Home Status Learn CGI Tests Templates Access Control Reference Manual