JavaServer Pages
The example in the previous paragraph would require writing some code that checked
whether the name of the lead signer matched the name of the author of the first track.
This is once again mixing programlike code with HTML, but because most of the hard
work is done in the objects or functions, all the HTML authors typically need to know is
some relatively simple control structures that do such things as compare two values or
loop through a set of values, performing some action on each.
So far in discussing templating, nothing has been said about performance. Not
surprisingly, the speed of such a system may be less than ideal. First, the CGI has to be
started, then it has to read the template, then it has to look for all the special tags and
process them, and so on. All other things being equal, a system like this is likely to be
orders of magnitude slower than a CGI written entirely in C.
There is still hope for templating by mixing it with the performance-improvement ideas
that were discussed previously. In particular, it is possible to turn the templating CGI into
an extension to the Web server, which will eliminate the need to start the CGI up each
time a template is needed. This also allows templates to save state information, use
shared resources efficiently, and so on. Many such templating systems are alive and well
today, from PHP, a well-known hypertext preprocessor that mixes scripting commands
with HTML; to WebSQL, a templating system that provides easy access to databases; to
osforms, a system built by Object Design to work with its object database.