You are on page 1of 33

ASP stands for Active Server Pages ASP is a Server Side Scripting Language ASP is a program that runs

ns inside IIS IIS stands for Internet Information Services IIS is a web-server Application made by Microsoft

An ASP file is just the same as an HTML file An ASP file can contain text, HTML, XML, and scripts Scripts in an ASP file are executed on the server An ASP file has the file extension ".asp"

Your own PC can act as a web server if you install IIS or PWS (personal web server) IIS or PWS turns your computer into a web server Microsoft IIS and PWS are free web server components

How to Install IIS on Windows 7 and Windows Vista Follow these steps to install IIS: Open the Control Panel from the Start menu Double-click Programs and Features Click "Turn Windows features on or off" (a link to the left) Select the check box for Internet Information Services (IIS), and click OK After you have installed IIS, make sure you install all patches for bugs and security problems. (Run Windows Update).

Follow these steps to install IIS: On the Start menu, click Settings and select Control Panel Double-click Add or Remove Programs Click Add/Remove Windows Components Click Internet Information Services (IIS) Click Details Select the check box for World Wide Web Service, and click OK In Windows Component selection, click Next to install IIS After you have installed IIS, make sure you install all patches for bugs and security problems. (Run Windows Update).

How to install PWS on Windows 95, 98, and Windows NT For Windows 98: Open the Addons folder on your Windows CD, find the PWS folder and runsetup.exe to install PWS. For Windows 95 or Windows NT: Download "Windows NT 4.0 Option Pack" from Microsoft, and install PWS.

<% // BODY OF SCRIPT %> 1.Generally Embedded in Html tags 2. Whenever serves sees the <% delimiter in the page it knows it must compute something before sending the response back.

In ASP you declare a variable with the use of the Dim keyword, which is short for Dimension. Dimension in english refers to the amount of space something takes up in the real world, but in computer terms it refers to space in computer memory. Variables can be declared one at a time or all at once. Below is an example of both methods.

<html> <body> <% dim name name="Donald Duck" response.write("My name is: " & name) %>

</body> </html> O/p ----My name is: Donald Duck

The response.write command is used to write output to a browser Shorthand <% ="Hello World!" %>

<html> <body> <% Dim famname(5),i famname(0) = "Jan Egil" famname(1) = "Tove" famname(2) = "Hege" famname(3) = "Stale" famname(4) = "Kai Jim" famname(5) = "Borge"

For i = 0 to 5 response.write(famname(i) & "<br />") Next %>


</body> </html>

Jan Egil Tove Hege Stale Kai Jim Borge

ASP's If Statement is slightly different than the If Statement implementation in most other languages. There are no brackets, or curly braces, nor are there any parenthesis. Rather the beginning of the code to be executed in the If Statementwhen its true is marked with Then and the end of the If Statement is plainly marked with End If.

<% Dim myNum myNum = 6 If myNum = 6 Then Response.Write("Variable myNum = 6") End If %> \\ Output Variable myNum=6

The variable that appears immediately after Select Case is what will be checked against the list of case statements. These case statements are contained within the Select Case block of code

<% Dim myNum myNum = 5 Select Case myNum Case 2 Response.Write("myNum is Two") Case 3 Response.Write("myNum is Three") Case 5 Response.Write("myNum is Five") Case Else Response.Write("myNum is " & myNum) End Select %>

The Session Object in ASP is a great tool for the modern web site. It allows you to keep information specific to each of your site's visitors. Information like username, shopping cart, and location can be stored for the life of the session so you don't have to worry about passing information page to page.

Variables stored in a Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires.

<% 'Start the session and store information Session("TimeVisited") = Time() Response.Write("You visited this site at: " & Session("TimeVisited")) %>

Here we are creating two things actually: a key and a value. Above we created the key "TimeVisited" which we assigned the value returned by the Time() function. Whenever you create a Session Variable to be stored in the Session Contents collection you will need to make this Key / Value pair.

<% Session("username")="Donald Duck" Session("age")=50 %> Retrieval When the value is stored in a session variable it can be reached from ANY page in the ASP application: Welcome <%Response.Write(Session("username"))%>

<% Session.Timeout = 240 Response.Write("The timeout is: " & Session.Timeout) %>

Timeout is 240 Minutes

What is a Cookie? A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.

The "Response.Cookies" command is used to create cookies.

<% 'create the cookie Response.Cookies("brownies") = 13 %>

Request.Cookies() is used. <% Dim myBrownie 'get the cookie myBrownie = Request.Cookies("brownies") Response.Write("You ate " & myBrownie & " brownies") %>

Unlike real life cookies, in ASP you can set how long you want your cookies to stay fresh and reside on the user's computer. A cookie's expiration can hold a date; this date will specify when the cookie will be destroyed.

In our example below we create a cookie that will be good for 10 days by first taking the current date then adding 10 to it. <% 'create a 10-day cookie Response.Cookies("brownies") = 13 Response.Cookies("brownies").Expires =Date() + 10 'create a static date cookie Response.Cookies("name") = "Suzy Q." Response.Cookies("name").Expires = #January 1,2009# %>

ASP v/s PHP

A COMPARISON of two Scripting languages !!!

ASP 1. ASP needs a Microsoft Server for the website to work

PHP 1. PHP or Hypertext Preprocessor, runs using Linux or Unix server. The more updated PHP programs can now run on an NT server. 2. PHP programs can also run in Windows, Solaris, Unix and Linux while ASP can only work with Window-based platforms

2. Recently, ASP can now run on a Linux platform given that there is an ASP-Apache program installed on its server.

3. ASP is very much similar to the 3. PHP uses C/C++ as base syntax and interface of Visual Basic language and most syntax are programming. similar to each other. Because a big chunk of programmers are still using C++ language, PHP are by far more popular than ASP. 4. ASP programs needs to run on Windows with IIS installed on the server. You need to purchase both of these components in order for ASP to work. 4. a PHP would only require running on a Linux server, which you can get at no cost.

5. if you were to use ASP, you need to purchase MS-SQL, which is a Microsoft product.

5. PHP is very much flexible when it terms of database connectivity. It can connect to several databases of which the most commonly used is the MySQL

6.ASP code runs slower.

6. PHP codes runs much quicker than ASP

In conclusion, both PHP and ASP have its own advantages and disadvantages. It basically depends on which part of developing a website you are most concerned with. Are you worried about the cost of creating your website? Do you want to use a programming language that you are more familiar with? Do you want a more stable and faster website? Choosing between ASP and PHP basically depends on your own personal preference. It doesn't hurt to confer with other programmers or webmasters and research more information on which programming would best fit the requirements of your website

You might also like