Detailed description of asp built-in object server

Source: Internet
Author: User
Tags metabase

Server object:

The Server object provides access to methods and properties on the Server. Most of the methods and attributes serve as functions of the utility.

Syntax

Server. property | method

Attribute

ScriptTimeout:
The ScriptTimeout attribute specifies the maximum time that a script can run before it ends. When processing server components, the timeout limit will no longer take effect.

Syntax Server. ScriptTimeout = NumSeconds

NumSeconds
Specifies the maximum number of seconds that a script can run before the end of the server. The default value is 90 seconds.

Note
You can use the AspScriptTimeout attribute in Metadatabase to set the default ScriptTimeout value for Web services or Web servers. The ScriptTimeout attribute cannot be set to smaller than the value specified in the metabase. For example, if NumSeconds is set to 10 and MetaBase is set to 90 seconds, the script times out after 90 seconds. However, if NumSeconds is set to 100, the script times out after 100 seconds.

For more information about using Metadatabase, see about Metadatabase.

In the following example, if the server processes the script for more than 100 seconds, it will time out.
<% Server. ScriptTimeout = 100%>
The following example obtains the current value of the ScriptTimeout attribute and stores it in the variable TimeOut.
<% TimeOut = Server. ScriptTimeout %>

Method

CreateObject
Create an instance of the server component by using the CreateObject method. If this component executes the OnStartPage and OnEndPage methods, the OnStartPage method is called. For more information about server components, see ASP components that can be installed.

Syntax Server. CreateObject (progID)

The progID parameter specifies the type of the object to be created. The progID format is [Vendor.] component [. Version].

Note by default, the object created by the Server. CreateObject method has a page scope. This means that after the current ASP page is processed, the server will automatically destroy these objects. To create an OBJECT with a SESSION or application scope, you can use <OBJECT> to mark and set the SCOPE attribute of the SESSION or APPLICATION, or store the OBJECT in the dialog and APPLICATION variables.
For example, in the following script, when the Session object is destroyed, that is, when the conversation times out or the Abandon method is called, the objects stored in the Session variable are also damaged.
<% Set Session ("ad") = Server. CreateObject ("MSWC. AdRotator") %>
You can destroy an object by setting the variable to Nothing or a new value, as shown below. The first example releases the ad object, and the second example uses a string to replace the ad object.
<% Session ("ad") = Nothing %>
<% Session ("ad") = "Other Valum" %>
You cannot create an object instance with the same name as a built-in object. For example, the following script returns an error.
<% Set Response = Server. CreateObject ("Response") %>

Example <% Set MyAd = Server. CreateObject ("MSWC. AdRotator") %>
In the preceding example, a MSWC. AdRotator server component named MyAd is created. The MSWC. AdRotator component can be used to automatically rotate advertisements on Web pages.
For more information about server Components, see Creating Components for ASP.

The HTMLEncode method applies HTML encoding to the specified string.

Syntax Server. HTMLEncode (string)

The string parameter specifies the string to be encoded.

Sample script <% = Server. HTMLEncode ("The paragraph tag: <P>") %>

Output The paragraph tag: & lt; P & gt;

Note that The above output will be displayed as The paragraph tag by The Web browser: <P> If you check The source file or open a Web page in text mode, you can see The encoded HTML.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.