What is Asp Server Object
The server object is used to provide several commonly used functions

, such as creating a new object , setting time-out property , and converting text

into HTMLs or URLs.

 

Methods Properties

Asp Server Object – Methods

1)Server.CreateObject()

-allows programmer to make instances of components that are running on the server.

There are lots of server components (for example AdRotator,ContentLinker,Browser

Capabilities) that we will see later.

The general syntax for establishing a reference to component of

the server object is:

<%

Set objName = Server.CreateObject(“ClassName.ComponentName”)%>

Eg.

<Set objConn = Server.CreateObject(“ADODB.Connection”)%>

2)Server.MapPath()

– maps the specific virtual path into corresponding physical directory in the

server.We will see this later in scripting object session.

Eg

<%

Server.MapPath(“/virtualpath”)

‘The result is C:\InetPub\wwwroot\virtualpath

%>

3)

Server.URLEncode()  -applies URL Encoding rules ,including escape character,

to a specific string.For example space is transformed into (+).

Eg

<%

Response.Redirect(“login.asp?name=”&Server.URLEncode(Request(“name”))&_

“&Password=”&Server.URLEncode(Request(“password”)))

%>

4

)Server.HTMLEncode() – applies HTML encoding to specific string.For example

wherever we find < or > we need to replace it with &lt; or &gt; respectively.

Eg

<%

str = “<body backgroundcolor=Red text=blue>”

response.write (Server.HTMLEncode(str))

%>

5)Server.Execute(path)

– calls an .asp file and processes it as if it were part of the calling

ASP script. The path parameter may be for either an absolute or a relative path.

If the path is absolute, it must map to an ASP script in the same application

as the calling Asp file.

Top


Asp Server Object – Properties

1)Timeout()

– maximum length of time in seconds before a script is terminated.

eg

<%

Server.ScriptTimeOut = 100

%>

Top


Leave a Comment