Server Side Includes

From Free net encyclopedia

Template:Cleanup-date

Server Side Includes or SSI is an easy server-side scripting language used almost exclusively for the web. As its name implies, its primary use is including the contents of one file in another.

It is common where the same lines of codes are repeated on more than one page within a website, for example to create a standard header of a website that is repeated on every page. This allows the webmaster to later on make small changes to the header without manual editing of every page within the website.

SSI-enabled HTML files usually use the extension *.shtml or, more rarely, *.shtm, although this depends on the scripting language used.

Contents

Basic syntax

SSI has a simple syntax: <!--#directive parameter=value parameter=value-->. Directives are placed in HTML comments so that if SSI isn't enabled, users won't see the SSI directives on the page, unless they look at its source.

Directives

These are the most common SSI directives:

Directive Parameters Description Example
include file or virtual This is probably the most used SSI directive, allowing the content of one document to be included in another. The virtual parameter, which specifies the file or script to be included, should be used instead of the file parameter. <!--#include virtual="header.html"-->
exec cgi or cmd If the cgi attribute is used, it should be the path to a CGI script to be executed. The PATH_INFO and QUERY_STRING of the current SSI script will be passed to the CGI script. include virtual should be used instead of exec cgi. <!--#exec cgi="/cgi-bin/foo.cgi"-->
or
<!--#exec cmd="ls -l"-->

Examples

The methodology of embedding programming languages within HTML is called server-side include and the programming language that is embedded within the HTML is called the scripting language. Netscape's Server-side JavaScript (SSJS), Microsoft's Active Server Pages (ASP), Sun Microsystems' JavaServer Pages (JSP), and open source PHP are examples of server-side includes. They respectively use JavaScript, VBScript (or JScript), Java, and PHP as the scripting language.

External links

See also

he:Server Side Includes pl:Server Side Includes ru:SSI