Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

Specifying Application Events

An ASP application starts the first time the Web server receives a request for one of the ASP pages contained in the application directory. The application ends when the Web server is shut down. You can create global data for an application using the built-in ASP Application object. You can assign variables and object instances to application variables so that they are available to all pages of an application.

When an application starts, the Application_OnStart event occurs. The Application_OnEnd event occurs when the application shuts down. When the application starts or stops, the server looks in the global.asa file to find the event scripts.

ASP Application_OnStart Event

The Application_OnStart event occurs before the first session is created, before the Session_OnStart event occurs. Only the Server and Application built-in objects are available. Referencing the Session, Request, or Response object in the Application_OnStart event generates an error.

Syntax: ASP Application_OnStart Event

<SCRIPT LANGUAGE=ScriptLanguage RUNAT=Server>

Sub Application_OnStart

. . .

End Sub

</SCRIPT>

Parameters: ASP Application_OnStart Event

ScriptLanguage

Specifies the scripting language used to write the event script, either VBScript or JScript. If more than one event uses the same scripting language, the events can be enclosed within a single set of <SCRIPT> tags.

Runat

Must be "Server."

ASP Application_OnEnd Event

The Application_OnEnd event occurs when the application ends, after the Session_OnEnd event (see below). Only the Server and Application objects are available.

Syntax: ASP Application_OnEnd Event

<SCRIPT LANGUAGE=ScriptLanguage RUNAT=Server>

Sub Application_OnEnd

. . .

End Sub

</SCRIPT>

Parameters: ASP Application_OnEnd Event

ScriptLanguage

Specifies the scripting language used to write the event script, either VBScript or JScript. If more than one event uses the same scripting language, the events can be enclosed within a single set of <SCRIPT> tags.

Runat

Must be "Server."

See also:

Managing User Sessions in this chapter

Using the global.asa File in this chapter

Saving Changes to the global.asa File in this chapter

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.