Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Perl CGl Programming: No experience required.
(Publisher: Sybex, Inc.)
Author(s): Erik Strom
ISBN: 0782121578
Publication Date: 11/01/97

Bookmark It

Search this book:
 
Previous Table of Contents Next


Skill 8
Creating Dynamic Web Pages: More Tools

  Using server-side includes (SSI)
  Generating graphics on the fly
  Making a graphical access counter

You’ve done some fairly substantial Perl programming by now if you’ve completed the exercises in the earlier chapters of the book. You should have a pretty good understanding of how Perl and the Common Gateway Interface work together to create dynamic, interactive Web pages.

In fact, your experience has probably led you to be a little frustrated with the limitations of HTML. It’s one thing to design and implement a full-blown CGI program for a relatively complex task such as a Web site guest book or an access counter. But what about something simpler, such as displaying a small document or using the Web server’s environment variables? Unadorned HTML can’t do it; you would have to write a CGI program.

Similarly, while HTML is quite good at displaying graphical images in the standard JPEG and GIF formats, it has no facility for manipulating them, or even making the simplest decisions.

Server-side includes (SSI) was invented to give some much-needed muscle to HTML. Indeed, as you’ll learn in this skill, SSI can be a very powerful tool. You’ll also learn about Ghostscript, a utility that you can use with Perl to create and manipulate graphics for your Web page.

Using Server-Side Includes

What are server-side includes? Weird as it may seem, the name actually is descriptive: SSI is a function of the Web server, so the processing of a command takes place on that side. One of the most useful—and often used—SSI functions allows you to include the contents of a file in an HTML document.


TIP:  C/C++ programmers encountering SSI for the first time will be reminded of their #include directive, which copies the contents of an external file. Perl programmers have a similar capability in the require function.

SSI is a set of directives to the Web server that are embedded in comment tags right in the HTML document. For example, the directive

   <!—#include file="NewStuff.html"—>

would copy the contents of NewStuff.html into the Web page, to be displayed by the visitor’s browser like any other HTML file.


NOTE:  Comments in HTML are statements enclosed by <!— and —> and are ignored by the Web server and the visitor’s Web browser. They are handy for documenting non-SSI HTML files. Also, if an SSI directive happens to be in a file being processed by a Web server that doesn’t do SSI, it too will be regarded as a comment and skipped over.

SSI is built into the Web server, which means that you don’t have it if your server doesn’t. The lack of SSI capabilities in a server is somewhat more prevalent than it used to be, now that more and more Web sites are being powered by non-UNIX operating systems. SSI is a standard feature of the NCSA and Apache servers; oddly, the CERN server won’t handle it. See the sidebar that follows about “Faking Out” the Cern Server.

In the PC world, the Sambar server supports the full set of SSI directives as of version 4.03 and Netscape’s latest Web server understands SSI, too. Microsoft’s Internet Information Server (IIS) is limited to one SSI command.

However, SSI is so useful that it won’t be the exclusive property of UNIX Webmasters for long. It’s worth your time and effort to learn the SSI commands, even if you can’t use them right away.

Assembling the SSI Directives

The list of SSI commands is not very long. However, you may be surprised at the power they can add to the simplest Web page.

The format of an SSI directive generally looks like this:

   <!—#DIRECTIVE PARAMETER="ARGUMENT"—>

Notice that the command is embraced by the HTML comment tags <!— and —>. It’s important that you don’t leave these out, because an SSI-enabled Web server will be looking for them to begin interpreting any embedded commands.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.