DM 171: Week Six - eXtended Server Side Includes

XSSI: Simple Yet Effective Programming for the Masses

Click on a tab to reveal its content…

  • In General
  • Environment
  • XSSI Commands

XSSI are powerful enough to replace functionally simple CGI scripts and do not require knowledge of Perl programming. One of the best sites to learn about simple programming with XSSI is “The World’s XSSI Cookbook” at There will be many references to the “Cookbook” as well as some paraphrasing; it is a clearly written tutorial that I am so thankful for that I keep a copy locally on my hard drive for reference.

The Neighborhood

The server and your browser create some data known as environmental variables. Knowing these will give you some ideas to be used with if instructions embedded in your pages. The <!--#printenv --> command can be used to show which variables can come into play. Create a page with the code below or download this page to be placed in your exercise three folder to give you a list of the variables.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>SSI Environmental Variables</title>

<h1>Server Side Includes - Environmental Variables

<!--#printenv -->


What does it all mean? Check the next tab.

Environmental Variables

These are some of the variables that the server keeps track of, notice that not all of them are supported since the “Result” is sometimes (none). Each installation of the Apache Server Software can have its own unique setup.

The results shown are for the server.

Code Description Result
AUTH_TYPE client authorization method if any (none)
CONTENT_LENGTH size of input posted from client (none)
CONTENT_TYPE MIME type of content (none)
DATE_GMT The current GMT time Thursday, 21-Mar-2019 01:19:16 GMT
DATE_LOCAL current time/date Wednesday, 20-Mar-2019 20:19:16 CDT
DOCUMENT_NAME document name that was requested xssi.shtml
DOCUMENT_URI URL of the document /dm171spring2010/schedule/week06/xssi.shtml
LAST_MODIFIED document modified date Thursday, 04-Dec-2014 15:12:38 CST
PAGE_COUNT number of accesses to current document (none)
HTTP_REFERER URL of the document the client came from (none)
REMOTE_ADDR Numeric IP address of the client
REMOTE_HOST domain name of the client (none)
REMOTE_USER ID of user (none)
SERVER_NAME server hostname
SERVER_PORT the port used by httpd 80
SERVER_PROTOCOL Which version of Httpd compliance HTTP/1.1
SERVER_SOFTWARE The name of the server software Apache/2.4
TOTAL_HITS total pages served by server (none)

Time Format Codes

Use these codes as values for <!--#config timefmt="..." --> to get the desired results when you echo the DATE_LOCAL. Once again, the values shown are for

Code Description Results
%a abbreviated weekday name Wed
%A full weekday name Wednesday
%b abbreviated month name Mar
%B full month name March
%c locale's appropriate date and time Wed Mar 20 20:19:16 2019
%C default date and time format 20
%d day of month - 01 to 31 20
%D date as %m/%d/%y 03/20/19
%e day of month - 1 to 31 20
%h abbreviated month name (alias for %b) Mar
%H hour - 00 to 23 20
%I hour - 01 to 12 08
%j day of year - 001 to 366 079
%m month of year - 01 to 12 03
%M minute - 00 to 59 19
%n insert a newline character
%p string containing AM or PM PM
%r time as %I:%M:%S %p 08:19:16 PM
%R time as %H:%M 20:19
%S second - 00 to 61 16
%t insert a tab character
%T time as %H:%M:%S 20:19:16
%U week number of year - 00 to 53 11
%w day of week - Sunday=0 3
%W week number of year - 00 to 53 11
%x Country-specific date format 03/20/19
%X Country-specific time format 20:19:16
%y 2 digit year - YY 19
%Y 4 digit year - YYYY 2019
%Z timezone name CDT

We learned last week about including other files with the include command:

<!--#include virtual="path_to_file" -->

The other commands are well documented at “The Worlds XSSI Cookbook” much better than I could; pay special attention to:

  • #config timefmt - to configure the homework footer date
  • #echo var - to get the date (and other variables)
  • #if expr, #elif expr, #else, #endif - the four commands used to craft your if/else programming for the contextual menu homework requirement
  • #set var with value - allow you to set your own variables if needed
  • The comparison operators and Boolean operations section is important to look over to use in your if/else programming.