Server-Side Include (SSI) directives are used to include one web page inside of another. It doesn't matter what type of web page it is: you can include static HTML (usually a .html or .htm extension) Javascript (.js) or ASP (.asp) into another page.
Most web servers allow you to nest includes so that page1.asp can include header.asp which in turn could include globals.asp. Most people don't like to have multiple levels of include files if they can possibly avoid it. It makes following the top-level pages that much more difficult.
There are two different types of ways to reference include files. With a virtual path, include files are referenced relative to the Web site root as in "/lib/mylibrary.asp". With a relative (file) include, the path is relative to the page that the directive is found on. Examples of both are shown below:
Virtual Include Directive
<!-- #include virtual="/lib/mylibrary.asp" -->
<!-- #include file="../lib/mylibrary.asp" -->
<!-- #include file="lib/mylibrary.asp" -->
A typical web page layout is shown below. The lines separate major areas of the web site that are common to all pages. We can make include files for all of the sections that don't change as you navigate through the site. In this case, the header, left nav and footer aren't going to change much.
+---------------------------+
| header |
|---------------------------|
| | |
| | |
|left| body |
|nav | |
| | |
| | |
+---------------------------+
| footer |
+---------------------------+
So the home page for this site might look something like the following:
<!-- #include virtual="/header.asp" -->
<table border=0 cellpadding=0 cellspacing=0 width="100%">
<tr>
<td valign="top" width="200">
<!-- #include virtual="/leftnav.asp" -->
</td>
<td valign="top" width="100%">
<!-- BODY START -->
<!-- BODY END -->
</td>
</tr>
<!-- #include virtual="/footer.asp" -->
So when you want to create a new page on your site, you can just copy this template to your new page and insert the new content within the BODY START and BODY END markers.
If you don't put your common code in include files like this, then whenever you want to make a change to the common elements, you would have to go through every single page on the site to make the same change. Using include files allows for easy site maintenance and consistancy throughout.