|May the source be with you, but remember the KISS principle ;-)|
|Contents||Bulletin||Scripting in shell and Perl||Network troubleshooting||History||Humor|
|News||Recommended Links||SSI Setup||Converting your documents to the SSI Format||SSI Environment Variables|
|Cheap Web hosting with SSH access||Humor||Etc|
Apache, NCSA HTTPd, Netscape Enterprise and several other servers allows users to include into document other documents from the current directory and/or simple information about the document. Such information can include the current date, the file's last modification date, and the size or last modification of other files. Having the server parse documents is a double edged sword. It can be costly for heavily loaded servers to perform parsing of files while sending them and can present a security risk. Therefore documents that need to parsed usually have a default extension shtml. User can specify directories to allow SSI.
To a certain extent SSI can be used as a "poor man" ASP.
Taking off with the idea of SSI, several companies including Cold Fusion and Net Objects designed custom web servers with incredible SSI functionality. These third party web servers provided a huge API which offered a host of server embedded resources which app developers could use to make their web pages dynamic that extended far beyond the limited set of commands offered by the operating systems.
They also provided a huge number of formatting options as well including complex tabular display.
Cold Fusion, perhaps the best-known SSI-based application server offers a set of over 70 custom "CFML" tags that execute most, if not all of your average needs on the custom Cold Fusion Web Server. Cold Fusion also allows you to set name/value pairs in your HTML as well.
CGI Programming Chapter 5 Server Side Includes
- Environment Variables
- Including Boilerplates
- File Statistics
- Executing External Programs
- Executing CGI Programs
- Tailoring SSI Output
- Common Errors
You're starting to get the hang of CGI, but aren't too thrilled with the fact that you have to write full-fledged CGI programs even when you want to output a document with only a minimum amount of dynamic information, right? For example, say you want to display the current date and time, or a certain CGI environment variable in your otherwise static document. You can go through the trouble of writing a CGI program that outputs this small amount of virtual data, or better yet, you can use a powerful feature called Server Side Includes (or SSI).
Server Side Includes are directives which you can place into your HTML documents to execute other programs or output such data as environment variables and file statistics. Unfortunately, not all servers support these directives; the CERN server cannot handle SSI, but the servers from NCSA and Netscape can. However, there is a CGI program called fakessi.pl that you can use to emulate Server Side Includes if your server does not support them.
While Server Side Includes technically are not really CGI, they can become an important tool for incorporating CGI-like information, as well as output from CGI programs, into documents on the Web.
How do Server Side Includes work? When the client requests a document from the SSI-enabled server, the server parses the specified document and returns the evaluated document (see Figure 5-1). The server does not automatically parse
[Mar 16, 2002] Webmaster's Guide to Server Side Includes - WebReference.com
[June 12, 2000] Apache Today - Apache Guide Introduction to Server Side Includes By Rich Bowen
This is the first of three articles dealing with Server Side Includes, usually called simply SSI. In this article, I'll talk about configuring your server to permit SSI and introduce some basic SSI techniques for adding dynamic content to your existing HTML pages.
In the second article, we'll talk about some of the somewhat more advanced things you can do with SSI, and in the third week, we'll look at the advanced things that can be done with SSI, such as conditional statements in your SSI directives.
What are SSI?
SSI (Server Side Includes) are directives that are placed in HTML pages and evaluated on the server while the pages are being served. They let you add dynamically generated content to an existing HTML page, without having to serve the entire page via a CGI program or other dynamic technology.
The decision of when to use SSI, and when to have your page entirely generated by some program, is usually a matter of how much of the page is static and how much needs to be recalculated every time the page is served. SSI is a great way to add small pieces of information, such as the current time. But if a majority of your page is being generated at the time that it is served, you need to look for some other solution.
Configuring Your Server to Permit SSI
To permit SSI on your server, you must have the following directive either in your
httpd.conffile or in a
This tells Apache that you want to permit files to be parsed for SSI directives.
Not just any file is parsed for SSI directives. You have to tell Apache which files should be parsed. There are two ways to do this. You can tell Apache to parse any file with a particular file extension, such as
.shtml, with the following directives:AddType text/html .shtml AddHandler server-parsed .shtml
One disadvantage to this approach is that if you wanted to add SSI directives to an existing page, you would have to change the name of that page, and all links to that page, in order to give it a
.shtmlextension, so that those directives would be executed.
The other method is to use the
XBitHacktells Apache to parse files for SSI directives if they have the execute bit set. So, to add SSI directives to an existing page, rather than having to change the file name, you would just need to make the file executable using
chmod.chmod +x pagename.html
A brief comment about what not to do. You'll occasionally see people recommending that you just tell Apache to parse all
.htmlfiles for SSI, so that you don't have to mess with
.shtmlfile names. These folks have perhaps not heard about
XBitHack. The thing to keep in mind is that, by doing this, you're requiring that Apache read through every single file that it sends out to clients, even if they don't contain any SSI directives. This can slow things down quite a bit and is not a good idea.
Of course, on Windows, there is no such thing as an execute bit to set, so that limits your options a little if you're running Apache on Windows.
Basic SSI Directives
SSI directives have the following syntax:<!--#element attribute=value attribute=value ... -->
It is formatted like an HTML comment, so if you don't have SSI correctly enabled, the browser will ignore it, but it will still be visible in the HTML source. If you have SSI correctly configured, the directive will be replaced with the results of the directive.
The element can be one of a number of things, and we'll talk some more about most of these in the next installment of this series. For now, here are some examples of what you can do with SSI.
Today's Date<!--#echo var=DATE_LOCAL -->
echoelement just spits out the value of a variable. There are a number of standard variables, which include the whole set of environment variables that are available to CGI programs. Also, you can define your own variables with the
If you don't like the format in which the date gets printed, you can use the
configelement, with a
timefmtattribute, to modify that formatting.<!--#config timefmt="%A %B %d, %Y" --> Today is <!--#echo var=DATE_LOCAL -->
Modification Date of the File</4>This document last modified <!--#flastmod file="index.html" -->
This element is also subject to
Including the Results of a CGI Program
This is one of the more common uses of SSI - to output the results of a CGI program, such as everybody's favorite, a hit counter.<!--#exec cgi="/cgi-bin/counter.pl" -->
We'll definitely come back to this in another article.
[July 10, 1999] Internetter Server Side Includes Tutorial
Softpanorama hot topic of the month
Author's Note: This article was written in 1995, so technical specifics may be out of date. However, the concepts still stand and I think this is a good introduction to what SSI's are and how/why they work.
For more information on SSI's, please the CGI Resources List of articles to continue your learning.
In Apache any document with handler of "server-parsed" will be parsed
for SSI, if the
Includes option is set. If documents containing
SSI directives are given the extension .shtml, the following directives
will make Apache parse them and assign the resulting document the mime type
AddType text/html .shtml AddHandler server-parsed .shtml
The following directive must be given for the directories containing
the shtml files (typically in a
<Directory> section, but this
directive is also valid .htaccess files if
You can use the program Perl scripts to add to you document footer and header SSI tags or other useful SSI. For adding footer and header tags Perl script exists. Usage is simple:
toshtml file.html header.html footer.html> file.shtml.
The document is parsed as an HTML document, with special commands embedded as SGML comments. A command has the syntax:
element attribute=value attribute=value ...
The value will often be enclosed in double quotes; many commands only allow a single attribute-value pair. Note that the comment terminator (-->) should be preceded by whitespace to ensure that it isn't considered part of an SSI token.
The allowed elements are:
bytesfor a count in bytes, or
abbrevfor a count in Kb or Mb as appropriate.
strftime(3)library routine when printing dates.
(none). Any dates printed are subject to the currently configured
The CGI script is given the PATH_INFO and query string (QUERY_STRING) of the original request from the client; these cannot be specified in the URL path. The include variables will be available to the script in addition to the standard CGI environment.
If the script returns a Location: header instead of output, then this will be translated into an HTML anchor.
include virtual element should be used in preference
/bin/sh. The include variables are available to the command.
sizefmtformat specification. Attributes:
timefmtformat specification. The attributes are the same as for the
An attribute defines the location of the document; the inclusion is done for each attribute given to the include command. The valid attributes are:
../, nor can it be an absolute path. The
virtualattribute should always be used in preference to this one.
A URL is constructed from the attribute, and the output the server would return if the URL were accessed by the client is included in the parsed output. Thus included files can be nested.
<!--#set var="category" value="help" -->
A number of variables are made available to parsed documents.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes. If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner.
ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least
Copyright © 1996-2016 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.
Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info|
The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: September 12, 2017