Krify Articles
  Sign Up | Log In     Krify Home | Videos | Buzz | Free SMS | Matrimony | Answers | Web Hosting | Bulk SMS | Mail | News | Blogs


Music | Shopping | Forums | Freelance | Wall papers | Classifieds | Web director | Greetings | Bookmarks | Search | Games | Adman

Home Recent Articles Popular Articles Article of the day
Category list


Advertisements Ask Questions, Share Knowledge with Krify Answers
 
Posted by:  radhesh
 Article viewed:  839  times



ASP(Active Server Pages)

 ASP(Active Server Pages)

Introduction to ASP:

Server Side Includes (SSI) are extremely useful, even though you may have never heard of them or known that you are experiencing them. SSI is a server side method of manipulating web pages which means that you do not need a specific browser to use them, and they will run on any computer.

You will never have noticed SSI before on a web page because nothing special appears, in fact the adverts at the bottom and side of this page are placed there using SSI. What SSI does is it tells the server to replace the SSI tag with something else, for example a piece of text. This is done when the page is requested and the user will see nothing different to if the text (or code) was already there (view the source of the page to see this).

Why Should I Use Them?

You are probably thinking that this seems a very strange way to include some text, or even some HTML code on your page. It seems like a bit of a waste of time when you could just enter it as you normally would. There are two great benefits of SSI, though. Firstly, you can get many pages to include the information from a single file so that you could, for example, include a standard footer on each page with your copyright information. You could then update all the pages by just changing this one page.

Secondly, you can get your SSI to execute a CGI script on your server. This allows you to have text counters, advanced advert rotations, random text and images and several other extras on your web pages. This is one of the best uses of SSI.

What Do I Need?

As I mentioned earlier, SSI tags are parsed server-side, not by the user s browser. This means that SSI must be set up on your server for them to work. You are unlikely to have SSI enabled if you do not have a CGI-BIN but if you do it is very likely that the server administrator will have enabled SSI.

To test whether SSI is set up on your server place the following code in an HTML page:

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

Then try to run this page on the server. If SSI is enabled the current date and time on the server will be displayed. If this does not work try renaming the page extension to .shtml instead of .html or .htm. Many servers require this for SSI to work. If neither of these work, check the source code of your page. If the SSI tag is still there there is a problem. E-mail the system administrator and ask him if SSI is enabled.

If you do not have SSI on your server then you could try one of the free web hosts that support it like
Virtual Avenue or Hypermart.

Including A File

This is one of the most simple things you can do using SSI. Create a text file with a little bit of text in it and save it. Upload it to your server. Then create an HTML file and add the following:

<!--#include virtual="myfile.txt" -->

The way in which this works is that the file is referred to relative to your accounts root. To explain this I will show what would happen if you had the file saved in a folder called common . Your site is at www.mysite.com.

To include this file from any page on your site you would use:

<!--#include virtual="/common/myfile.txt" -->

This would be the same even if it was on the page www.mysite.com/index.htm or www.mysite.com/html/files/myfile.htm

An easy way to work out what the path would be is to take your domain name (or sub domain) off the file s name:

http://www.mysite.com/common/myfile.txt

in this example. The obvious benefit of this is that you don t even have to keep updating the code on each page like you would with an image or a link.

SSI

Introduction

In the last part I explained what SSI is and what it can be used for. In this part I will show you how using it with a script is useful and how you can include certain information into your page.

Scripts

One major use of SSI is to include the output from a script in your page. As I explained in the last part, the adverts a the bottom and side of this page are placed there using SSI. There is a very simple CGI script which, every time it is run, generates the code for an advert to place on the page.

This file is then called via a standard SSI call (like for any other file) with a slight change (although include virtual usually also works):

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

As well as for advertising rotation, SSI can be used with many other scripts, for example to display a textual visitor count on your page or to do an image or text rotation on a page of your site. It can even be used in conjunction with a content gathering script to seamlessly integrate it into your pages.

Preset Commands

SSI can also be used to display information on your page which is preset by the server. One of the major uses in the date and time command which is used as follows:

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

which appears like this:
Friday, 12-Apr-2002 11:03:34 EDT
(this is not a live example, the true system time would be shown on a real ssi page)

This is the date and time on the server your site is hosted on. You can also display the date and time in GMT using:

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

The format the date and time appear as may not be what you want so you can format it using the Timeformat command before the date command, for example:

<!--#config timefmt="%A, %d %B %Y"--><!--#echo var="DATE_LOCAL"-->

which will display:
Friday 12 April 2002
(again this is not a live example)

The time format is made up of some codes which you can separate as you want them to appear (like the comma I used above). Here is a list of some of the codes you can use:

Code

Function

Examples

%A

Full weekday name

Monday, Wednesday

%a

Abbreviated weekday name

Mon, Wed

%B

Full month name

January, December

%b

Abbreviated month name

Jan, Dec

%d

Number of day in month

03, 1500
01/font>

%e

Number of day in month

3, 15

%H

Hour (1-24)

05, 22

%I

Hour (under 12)

03, 11

%j

Day number in year

12, 245

%m

Number of month

1, 12

%M

Minute

12, 59

%p

AM or PM

AM, PM

%n

New Line



%S

Second

12, 57

%t

Tab

%y

2 Digit Year

99, 03

%Y

4 Digit Year

1999, 2003

%Z

Time Zone

EST, GMT


As well as the time there are several other preset commands you can use inc
luding:

Document Name (the file s name):
<!--#echo var="DOCUMENT_NAME"-->

Doucument s URL (the part after the domain name)
<!--#echo var="DOCUMENT_URI"-->

Refering Page:
<!--#echo var="HTTP_REFERER"-->

Users IP Address:
<!--#echo var="REMOTE_ADDR"-->

There are some others as well, although these are the most useful.

What Next

Now you have learned the basics of using SSI you will probably find that you can t do without it! If you want to find out some of the other preset commands in SSI you can do a search on your favorite search engine.

Disclaimer: The above article is responsible of the individual who post, krify.com does not hold responsible for any kind of disinformation. If you discover one or more of the krify.com pages direct you to messages that harass, abuse, have obscene, unlawful, defamatory, libellous, hateful, or otherwise objectionable content; or have spam, please inform to krify.com and that will be deleted as soon as possible.

Other interesting Article in the Category Programming
  Write Your First Application in Win32 using Assembly Language
  APPLYING FORMULA IN A TABLE
  The First Cup of Java
  Dynamic-link library
  XML Parsing using PHP (Easy)
  Prevent mistypings to the String class
  Memory Management with PHP
  Take Command with AJAX
  Introduction to C++
  Event Handling and Interfaces in .NET

Write your Comment
Name:
Message:
 Verification code:    

Home Email to Friend
Google Pack

© Copyright - 2007 KRIFY SOFTWARE TECHNOLOGIES (P) LTD