To read the article online, visit

Using Server-Side Directives

We're all probably very familiar with using:

<!--#include file="somefile.asp"-->

in our ASP scripts. (If not, I highly recommend you check out the article, The Low-Down on #includes.) The #include is referred to as a server-side include, since it includes a text files on the server into a currently executing script. Only certain files with certain extensions can use server-side includes, or SSIs. These are files with the extension: .asp, .stm, .shtm, and .shtml. (Through IIS you can setup other extensions to incorporate SSI; for more information read The Low-Down on #includes.)

Well, did you know that there are other server-side directives available for use? The disadvantage here is that these server-side directives can only be used with files that are processed with SSINC.DLL, which are, by default, .stm, .shtm, and .shtml, NOT .asp! So, you cannot use these additional server-side directives with .asp files, just with .stm, .shtm, and .shtml files.

Now, that may seem like a major drawback, and it is a downer, I agree, but that doesn't mean we should not learn about the other server-side directives. In fact, using these server-side directives we can easily obtain information about various files on the web server. Let's say that we have a text file (named LatestResults.txt) on our webserver that is modified often by an ASP script. At any point in time, we'd like to know the file size and last modified date of this text file. We could write an ASP script to display this information, but why not use some server-side directives? All we need to use is #fsize and #flastmod.

Start out by creating a file with an appropriate extension: I choose to name this file LatestResultsInformation.shtml. Next, add the following lines into LatestResultsInformation.shtml:

<!--#config SIZEFMT="BYTES"-->
LatestResults.txt File Size = <!--#fsize file="LatestResults.txt" -->

The #config statement sets the formatting.

<!--#config SIZEFMT="BYTES"-->

displays the filesize in bytes.

<!--#config SIZEFMT="ABBREV"-->

displays the filesize rounded off to the nearest kilobyte. Note the file="LastestResults.txt". You can replace the keyword file with the keyword virtual. For a discussion on the differences between using file and virtual with server-side directives, refer to The Low-Down on #includes. Now, let's look at how to use the directive #flastmod to display the last modified date of a file. Before we do that, though, let us look at how we can use #config to format the output of #flastmod. #config takes a format string, like so:

<!-- Display the time in MM/DD/YY - HH:MM:SS -->
<!-- #config timefmt="%m/%d/%y - %I:%M:%U" -->

A complete listing of the format symbols for #config can be found at Once we setup the format, all we need to do is simply use #flastmod much like we used #fsize:

LatestResulsts.txt Last Modified on
<!--#flastmod file="default.asp"-->

Pretty neat, eh? You can also use server-side directives to output server variables. You've probably looked at the Request.ServerVariables collection, and used ASP to view those. (If you are unfamiliar with Request.ServerVariables, please read: Using Request.ServerVariables.) To display the server variables using server-side directives, we simply use the #echo command.

<!--#echo var="SCRIPT_NAME"-->

This will print out the name of your currently running script. This is synonymous to:


Well, I hope this article has taught you something new! Now go out there and use server-side directives!! :)

Happy Programming!

Article Information
Article Title: Using Server-Side Directives
Article Author: Scott Mitchell
Published Date: Wednesday, August 25, 1999
Article URL:

Copyright 2019 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers