gotFusion.com....... Where your adventure begins
Full Service Web HostingNetObjects Fusion 7 Websites Portal

 


 

The Server Object
The ASP Server object is used to access properties and methods on the server.
Its properties and methods are described below:

Properties

Property

Description

ScriptTimeout

Sets or returns the maximum number of seconds a script can run  before it is terminated by the server The default value is 90 seconds

It can be changed to a desired amount greater or less than 90 seconds

Syntax: Server.ScriptTimeout = number of seconds

Example:
<%
Server.ScriptTimeout = 120
%>



Methods

Method

Description

CreateObject

Creates an instance of an object. This is an important part of the query exchange and data appending, deleting, editing process. It is also used for Creating Objects for use like smtp sessions, html retrieval, etc.

Syntax: Server.CreateObject(progID)
Where ProgID is the type of object you are creating.
For Example:
<%
Dim rs
Set rs = Server.CreateObject("ADODB.RecordSet")
%>

Creates an Object for connecting to and displaying or updating information in a data source.
There are several Object types you can create depending on the applications and services installed on the server. You can look at this as another way of declaring <object> tags.

Here are a few examples
Server.CreateObject("ADODB.RecordSet")
Server.CreateObject("ADODB.Connection")
Server.CreateObject("Microsoft.XMLHTTP")
Server.CreateObject("CDONTS.NewMail")

Execute

Executes an ASP file from inside another ASP file.
This Method can not be looked at as the equivilent of a SSI Server Side Include using the html fragment <!--#include file="filename.asp" --> The reason is the Include syntax loads another asp page "before" running any code.
The execute method executes another asp application page while processing is being performed.

You can use this to call another asp file and run that script then return to the parent script

Syntax: Server.execute("myaddin.asp")

GetLastError()

Returns an ASPError object that describes the error condition that occurred

HTMLEncode

Applies HTML encoding to a specified string
Syntax: Server.HTMLEncode("string to encode")

Example:
Server.HTMLEncode("Encode tag for <Form>")

Outut in the source appears:
Encode tag for &lt;Form&gt;

Display would be :
Encode tag for <Form>


MapPath

Maps a specified path to a physical path

You will use this alot with ADO for connecting to db's
Syntax: Server.MapPath("path")

The "path" is required. This is a relative or virtual path to map to a physical path. If this value starts with / or \, it returns a path as if this value is a "full" virtual path. If this parameter does not start with / or \, it returns a path relative to the directory the asp file in process resides

Examples: Using the following

<%
response.write(Server.MapPath("guestbook.asp") & "<br>")
response.write(Server.MapPath("/source/guestbook.asp") & "<br>")
response.write(Server.MapPath("\Source") & "<br>")
%>


will return results similar to this... ( Your system may vary due to configuration. This assumes default IIS configuration)

c:\inetpub\wwwroot\source\guestbook.asp
c:\inetpub\wwwroot\source\guestbook.asp
c:\inetpub\wwwroot\scource

URLEncode

Applies URL encoding rules to a specified string
Syntax: server.URLEncode("value")

Example:
Server.URLEncode("http://www.gotfusion.com")

will return in the source

http%3A%2F%2Fwww%2Egotfusion%2Ecom

Spam protect could be one of the uses

View the PREVIOUS page in this tutorial

Return to the TOP of this page


|  Fusion  |  Web Design  |  Hosting  |  Resources  |  gotFusion Store  | 

Problems with this page?  

All content copyright © 2002 gotFusion LLC.  The name gotFusion and the gotFusion ® logo are registered trademarks of gotFusion LLC
Copyright, legal notice & privacy statement