Server-Side Includes

FeatureSyntaxExample
Automatically-updated timestamps <!--#echo var="LAST_MODIFIED" --> Updated Sunday, 23-Jan-00 12:42:58 PST
"Include" files -- boilerplate, maintain just one copy <!--#include file="footer.txt" --> Questions or comments? E-mail the webmaster.
Run local commands in shells or interpreters, capture output in web pages <!--#exec cmd="dir" -->
01/23/00  02:17p     166 haha.html
05/20/98  09:59a   1,673 index.html
     2 File(s)     1,839 bytes
Automated file size measurement <!--#fsize file="twain.gif" --> 115K

Lab

  • Add the following code to your web page:
    <p>
    Your browser is:
    <!--#echo var="HTTP_USER_AGENT"-->***
    <p>
    This document was last updated on:
    <!--#echo var="LAST_MODIFIED"-->***
    <p>
    Files:
    <!--#exec cmd="dir"-->***
    <p>
    Note: replace dir with ls -l on Unix.

  • View the document in your browser. Do not open it as a local file; have a web server deliver it.

  • The URL shown in the browser's location field must start with http not with file.

  • Thus, you must first have uploaded your web page to a server, or installed a server locally.