A component can be instantiated by having it set to an object variable. Once instantiated, the properties, methods, and events of the object can be accessed. EG: This creates and uses a File System Object:
Set fso = CreateObject("Scripting.FileSystemObject") Set myFile = fso.CreateTextFile("c:\Inetpub\wwwroot\test.htm", True) myFile.WriteLine("<html><head><title>hi</title></head>") myFile.WriteLine("<body><p>hi</p></body></html>") myFile.Close Set fso = Nothing Set myFile = Nothing
Another ASP page can be executed from within another.
Response.Write "Heres stuff from another ASP page:" Server.Execute "another.asp"
The Server object offers two methods that encode a string;
Response.Write(Server.HTMLEncode ("<br />")) 'Returns: <br />
<% Response.Write(Server.URLEncode ("Hello world!")) %> 'Returns: Hello+world%21
Server.MapPath can take a real or imagined relative or virtual path and converts it to a command line path.
Server.MapPath "index.htm" 'Returns: c:\inetpub\wwwroot\sub\index.htm
Sets number of seconds that a ASP process can run on the server before it terminates. The default value is 90 seconds.
Creates instance of a server component, including ActiveX components.
Here is the format for
The created object can be pointed to by a variable in any ASP page. If the object is to have session or application scope, then either:
- The created object must be set to a Session or Application variable in the Global.asa file.
- The object must be created with an <object> tag whose SCOPE attribute has been set to SESSION or APPLICATION.
Calls another ASP file and executes it. Sort of like an SSI (Server-Side Include) and sort of like a procedure call.
- Query strings that were available to the including file will be available to the included file.
- The response from the included file will be inserted at the point where
PathToASPmay be absolute or relative but absolute paths must be part of the same ASP application.
PathToASPcannot contain a query string.
Returns an ASP ASPError object. This method must be used before any content has been sent to the client.
500;100 custom error has occured, then IIS automatically transfers from the erring page to the default error handling error page located at
500;100 custom erroris generated if an error occurred on an ASP or the
- The default error handling page may be modified or changed to a different page altogether.
Returns a string where the following characters are encoded:
- ASCII characters above x80 are converted to
Translates the relative or virtual
path to its command line path on the server. In the following examples, assume that the file making the calls is
path does not start with a forward (
/) or backward slash (
\), then the returned path is relative to the file making the call to
Server.MapPath "fake.htm" 'Returns: c:\inetpub\wwwroot\sub\fake.htm
Server.MapPath "marine" 'Returns: c:\inetpub\wwwroot\sub\marine
Server.MapPath "marine/fake.htm" 'Returns: c:\inetpub\wwwroot\sub\marine\fake.htm
Server.MapPath "../marine 'Returns: c:\inetpub\wwwroot\marine
Server.MapPath "../marine/fake.htm" 'Returns: c:\inetpub\wwwroot\marine\fake.htm
path does start with a forward (/) or backward slash (\), then the returned path is
path appended to the virtual path (i.e. the root path of the site):
Server.MapPath "\fake.htm" 'Returns: c:\inetpub\wwwroot\fake.htm
Server.MapPath "/marine" 'Returns: c:\inetpub\wwwroot\marine
Server.MapPath "/marine/fake.htm" 'Returns: c:\inetpub\wwwroot\marine\fake.htm
Here are two particular "tricks":
Server.MapPath Request.ServerVariables("PATH_INFO") 'Returns: c:\inetpub\wwwroot\sub\me.asp 'i.e. of the current file
Server.MapPath "\" 'Returns: c:\inetpub\wwwroot 'i.e. of the virtual root
New with IIS 5.0. Sort of like Response.Redirect(URL) except that execution is transferred to another file on the server, instead of going back to the clients browser and having them execute a new request.
PathToASP cannot contain a query string.
Server.Transfer() can only transfers to the same server, whereas Response.Redirect() can redirect to sites not on the same server. The target URL will also think that its URL is the URL where the Server.Transfer() method was used.
If PreserveForm is set to True, than the target URL has the query string and form info available to it.
Also all the state information of the built-in objects are also transferred to the new page. This includes the following:
- Session and application scope variables.
- All the collections of the ASP Request object.
Returns a string encoding certain characters (including spaces) in a string (usually a URI) with a 2 digit escape sequence (EG:
%26) representing the ISO Latin 1 encoding of the character.
The following characters are not encoded:
* @ - _ + . /, plus ASCII alphanumeric.
This is equivalent to the
Escape() function built into VBS. ASP does not have an equivalent to the JS
unescape() or the VBS