Michael Doran Home Page
Contact | Site Map | Search  
  Home > Archives > Server Side Includes > Examples
This page is deprecated: please read archives disclaimer.

Server Side Includes

Examples


Including static content in a page

Code <!--#include file="boilerplate.inc"-->
Result
US flag   Four score and seven years ago, our fathers brought forth on this continent...
Code <!--#include virtual="/doran/ssi/boilerplate.inc"-->
Result
US flag   Four score and seven years ago, our fathers brought forth on this continent...

Echoing environment variables   (some additional examples)

Code <!--#echo var="DATE_LOCAL"-->
Result Sunday, 22-Nov-2009 15:37:12 CST
(A different date format can be specified.)

Showing file size

Code file is <!--#fsize file="big-file.tar.gz"--> in size
Result file is 71K in size

Executing a server command

Code <!--#exec cmd="/opt/sfw/bin/gdate '+%B %e, %Y'"-->
(Use an absolute path to operating system command.)
Result November 22, 2009

Executing a CGI program

Code <!--#exec cgi="rotate-robot.cgi"-->
(In this example, refreshing the page randomly picks a robot to display.)
Result
Red Robot
"Crush, kill, destroy."
    - Red Robot

Server Side Include error messages (when things go wrong)

Code <!--#include virtual="./missing-file.inc"-->
(In this example, we are trying to include a non-existent file.)
Result [an error occurred while processing this directive]
Code <!--#config errmsg="[d'oh!]"-->
(Here is how you would personalize the error message.)
Result [d'oh!]