This document describes the various aspects of ASP develoment. Active Service Pages (ASP) is a Microsoft Technology used for server side computation for web based systems.  It gets executed on a Internet Information Server (IIS).

1.1   Standard Variables

Some standard variables are available globally in a ASP environment.  

These variables are:

1.1.1   Request

Request object is available in the ASP environment. It contains all the form values which gets posted to the web server. The values from the Request object can be obtained by two ways.  If the form actions is Post, then the values should be returned using the Form() method.

Request.Form("key")

And for Get action, QuseryString() method should be used.

Request.QueryString("key")

If we are not sure whether to retrieve from Form or QueryString, just get it from the Request object

Request("Key")

1.1.2   Response

Response object sends the reponse back to the client. Some of the operations of Response object are

Response.Write "An Error has occurred: " & Err.Description

Response.End

The End operation on the Response object will make the server to display whatever on the Response object on the page.  The redirect method will take the user to the redirected page.

Response.Redirect "login.asp"

1.1.3   Session

Session object is a place holder object in the web server.  It can be used to retain values between user requests.

‘to get the value

Set value = Session("key")

‘to set value

set Session("key") = value

1.1.4   Server

Server is the object which performs operation on the host machine.  New objects can be created using the creatObject method

set rs = server.CreateObject ("ADODB.Recordset")

2   VB Script

VB Script can be used for serve side scripting on ASP pages.  The VB script are marked with <% %> and <%= %>.  The tag with the = places the value on the page.  The followi9ng sections describe the various functions available

2.1   String Operations

Function

Description

Left

gets the portion of the string from left side

Left(str1,7)

This will get 7 characters from left side

Right

gets the portion of the string from right side

Rightt(str1,7)

This will get 7 characters from Right side

Mid 

is used to grab characters from the middle of a string

Mid(str1, 20, 7)

This will get 7 characters from the 20th position

Instr 

This method searches for a string in another string and returns the beginning position of the found string

arrowPos = InStr(20, str1, ">")

This will search for “>”  in String str1 starting from position 20

Split

This method will split the string into a series of substrings based on a delimiter

namevalues = Split(str1, ",")

This will split the string str1 with delimiter as comma and returns an array of substrings

&

& will append two strings

str3 = str1 & “ “ & str2

This will append str1 and str2 with a space in between

3   ADO

ADO is ActiveX Data Objects which are used for accessing databases like MS Access DB, SQL Server, Excel Spread sheet etc. ADO comes with the following classes

3.1   Connection

Connection object is used to connect to a data source, remote or local

conn = server.CreateObject("ADODB.Connection")

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\example.mdb"

Session("Connection").Open strConnection

3.2   RecordSet

This is the result object, returned after a query is executed

Set rs = server.CreateObject ("ADODB.Recordset")

rs.Open(SQLString, conn, 0, 1)

While Not rs.EOF

Value1 = rs("key1")

end

The example above creates a resultset object and opens it for a sql query SQL String by using a connection object conn. Then it loops through the recordset and retrieves values out of it.