spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column2


Server-side Includes

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

You can use server-side includes in various ways to display the date on a Web page. However, we do not recommend this method, because server-side includes increase the time it takes users to access your Web pages. Furthermore, turning on server-side includes may pose a security risk to your system.

If you decide to use a server-side include to display the date, despite the disadvantages, you must make sure they are turned on. For more information on enabling server-side includes, check out the NCSA HTTPd documentation.

The first step is to create a CGI (Perl) script that prints the date in the desired format. Simply copy the following code and paste it in a text file named display.pl (the file must be located in the cgi-bin directory):

# change this to perl's real path
#!/usr/bin/perl

sub curDate {
  # replace localtime with gmtime for GMT (UTC)
  my($sec,  $min,  $hour, $mday, $mon,  $year, $wday, $yday, -->
$isdst) = localtime(time); 
  my $monthName = ("January", "February", "March", "April", -->
"May", "June", "July", "August", "September", "October", -->
"November", "December")[$mon];
  ("$monthName $mday\, " . (1900 + $year));
}

print "Content-type: text/html\n\n"; # HTTP header
print &curDate;

Now add the following code segment (a "server-side include") to your HTML document:

<!--#exec cgi="/cgi-bin/display.pl"-->

You should enter the virtual path to the script (display.pl), or the full URL. This is not the script's real path, but the one you would use to execute it with your browser.

http://www.internet.com


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger


Created: September 11, 1997
Revised: April 7, 1998

URL: http://www.webreference.com/js/column2/include.html