Did you find this useful?
Socialize it today.


ASP Server Object

Wednesday, September 05, 2012

tags ASP

The ASP Server object is used to access methods and properties on the server. The Server object provides a variety of functionality such as the ability to execute other ASP pages within a page, or map a virtual path on the physical server. The syntax, properties and methods of the ASP Server object are as follows:


Properties

PropertyDescription
ScriptTimeoutThe ScriptTimeout property sets or returns the maximum amount of time, in seconds, that the script in the page can run before it is terminated. The default value is 90 seconds.


Setting the ScriptTimeout Value

<%
Server.ScriptTimeout=value in seconds

Server.ScriptTimeout=90
%>

Retrieving the value of the ScriptTimeout Property

<%
Response.Write(Server.ScriptTimeout)
%>

Methods

MethodDescription
CreateObjetThe CreateObject method creates an instance of the object such as a component, application or a scripting object. Once instantiated, the objects properties and methods are exposed.
ExecuteThe Execute method executes another ASP page from within the ASP page, without leaving the current page.
GetLastErrorThe GetLastError method returns an ASPError object that describes the error condition that occurred.
HTMLEncodeThe HTMLEncode method applies HTML encoding to a specified string. All non-legal HTML characters are converted to their equivalent HTML entity.
MapPathThe MapPath method maps a specified virtual or relative path to a physical path on the server.
TransferThe Transfer method sends all current state information to another page specified in the URL.
URLEncodeThe URLEncode method applies URL encoding rules to a specified string. All characters that are not valid in an URL are converted to their equivalent HTML entity.


CreateObject

Syntax
set variable=Server.CreateObject(progID)

<%
set objCmd=Server.CreateObject("ADODB.command")
%>

Execute

Syntax
Server.Execute(path)

<%
Server.Execute("page2.asp")
%>

GetLastError

<%
Server.GetLastError()
%>

HTMLEncode

Syntax
Server.HTMLEncode(string)

<%
Response.Write(Server.HTMLEncode("A paragraph element uses the <p> tag."))
%>

MapPath

Syntax
Server.MapPath(path)

<%
Response.Write(Server.MapPath("default.asp") & "<br />")
Response.Write(Server.MapPath("images/img1.jpg") & "<br />")
%>

Output
c:\inetpub\wwwroot\default.asp
c:\inetpub\wwwroot\images\img1.jpg

Transfer

Syntax
Server.Transfer(path)

<%
Server.Transfer("page2.asp")
%>

URLEncode

Syntax
Server.URLEncode(string)

<%
Response.Write(Server.URLEncode("http://www.itgeared.com"))
%>

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

Sams Teach Yourself Active Server Pages 3.0 in 21 Days ASP In A Nutshell Beginning ASP Databases