The ASP Server object is used to access the Server’s properties and methods. The ASP Server object has several methods and one property, and we’ll discuss the most important of them.
The Server.ScriptTimeout property defines the amount of time in seconds that an ASP script can run before it times out.
One of the most important ASP Server object methods is the Server.CreateObject. The Server.CreateObject method is used to create an instance of server component. Here is how to create an ADO database connection object instance, by using Server.CreateObject method:
Set objConnection = Server.CreateObject(“ADODB.Connection”)
The only parameter that the CreateObject takes (“ADODB.Connection” in the above example) specifies the type of object to be created. The Server.CreateObject doesn’t have a return value.
The Server.Execute method, executes an ASP page as a part of the parent (calling) ASP page. Here is an example of the Server.Execute use:
The Server.MapPath method maps a virtual or relative path to the related physical directory (directory path) on the server. Here is how to use Server.MapPath:
strAccessDBLocation = Server.MapPath(“db/myAccessDB.mdb”)
If the ASP script executing the line above resides in C:\Inetpub\wwwroot\App1 then the strAccessDBLocation will have the following value:
The Server.HTMLEncode method applies HTML encoding to the parameter string. Encoding data may help you prevent using unsafe characters by converting them to their HTML-encoded equivalent.
Response.Write Server.HTMLEncode(“100 is > than 1.”)
The above line will print:
100 is > than 1.