Server-side includes

A server-side include (SSI) is a feature provided by HTTP servers to automatically insert content into an HTML file as it is being sent out. When that feature is turned on in the HTTP server, then each HTML file that is being sent is scanned by the server. The server looks for special markup that provides instructions for inserting content. The instructions can insert static content files, or can initiate scripts to generate dynamic content.

The syntax used for SSI instructions varies with the server setup. The examples here show the syntax for a standard Apache SSI and for a Java ServerPages (JSP) inclusion. To produce output at the top of an HTML page generated by DocBook XSL, the examples are added to a user.header.content customization, which is described in the section “HTML headers and footers”.

<xsl:template name="user.header.content">
    <!-- Apache SSI -->
    <xsl:comment>#include virtual="/cgi-bin/"</xsl:comment>
    <!-- JSP inclusion -->
    <xsl:text disable-output-escaping="yes">
       &lt;%@ include file="/header.html" %>

Here is the output generated by this template:

<!--#include virtual="/cgi-bin/"-->
<%@ include file="/header.html" %>

The Apache SSI instruction is output in a standard HTML comment. When a comment starts with #include, then server in which SSI is turned on will act to execute the specified CGI script and insert the output of the script.

The JSP instruction is output between the character sequences <% and %>. Since this syntax is not an HTML element, comment, or processing instruction, the left angle bracket has to be escaped to be output. That's why the example uses the disable-output-escaping="yes" attribute on the xsl:text element that contains the instruction.

When this HTML file is requested by a browser, a properly configured HTTP server will execute these instructions and fill in the content before sending out the file.