Deitel & Associates, Inc. Logo

Back to
digg.png delicious.png blinkit.png furl.png
Internet & World Wide Web How to Program, 3/e
Internet & World Wide Web How to Program, 3/e

© 2004
pages: 1420

Amazon logo

This tutorial shows how to use Perl server-side includes (SSIs) to add dynamic content to a Web page. In particular, we demonstrate a Web page hit counter. The tutorial is intended for students and professionals who are already familiar with Perl programming.
Download the Code Example
[Note: This tutorial is an excerpt (Section 25.6) of Chapter 25, Perl, from our textbook Internet & World Wide Web How to Program, 3/e. This tutorial may refer to other chapters or sections of the book that are not included here. Permission Information: Deitel, Harvey M. and Paul J., INTERNET & WORLD WIDE WEB HOW TO PROGRAM, 3/E, 2004, pp.866-870. Electronically reproduced by permission of Pearson Education, Inc., Upper Saddle River, New Jersey.]
25.6 Server-Side Includes
Dynamic content greatly improves the look-and-feel of a Web page. Pages that include the current date or time, rotating banners or advertisements, a daily message, special offers or company news are attractive because they are current. Clients see new information on every visit and thus will likely revisit the site in the future.
Server-Side Includes (SSIs) are commands embedded in XHTML documents to create simple dynamic content. SSI commands like ECHO and INCLUDE enable the inclusion on Web pages of content that is constantly changing (i.e., the current time) or information that is stored in a database. The command EXEC can be used to run CGI scripts and embed their output directly into a Web page.
Not all Web servers support the available SSI commands. Therefore, SSI commands are written as XHTML comments (e.g., <!--#ECHO VAR="DOCUMENT_NAME" -->). Servers that do not recognize these commands treat them as comments. Some servers do support SSI commands, but only if they are configured to do so. Check your server's documentation for instructions on how to configure your server to process SSI commands properly. Please refer to
if you are running the Apache Web server, or
if you are running a version of IIS.
A document containing SSI commands is typically given the .shtml file extension (the s at the front of the extension stands for server). The .shtml files are parsed by the server. The server executes the SSI commands and writes output to the client.

Performance Tip 25.1
Parsing XHTML documents on a server can dramatically increase the load on the server. To increase the performance of a heavily loaded server, limit the use of server-side includes.
Page 1 | 2 | 3 | 4
Return to Tutorial Index