Home
Home Page
Processing of tags html in TextField
Web 2.0 for designers
That in exchange
Keshirovanie registrations
Semantic web. A note about logical and illogical imposition
XHTML, speak?
Lessons of ASP-technologies
Often asked questions (FAQ) about ASP
Complex  regular expressions
Receptions of network defense on PHP
Receptions of network defense on PHP - 2
Development objective orientirovannosti PHP
Banner business
Use Output Buffering in PHP
Use Output Buffering in PHP
Doloj procedural programming, you allow object-oriented!
How to learn{find out}, whence there came visitors
Links

Lessons of ASP-technologies

Object Application


Now let's consider object Application. He is intended for storage of global variables of the ASP-application, that is variables which are accessible to each session of the application. These variables are in collection Contents to which usually address in abbreviated form. For example, we shall write down the following code in a file default.asp.

<%

Application ("name") = "test"

%>



Then we shall create a file test.asp and we shall type{collect} such code:

<%

Response. Write Application ("name")

%>



After that we shall execute the script default.asp, and then test.asp. Last will deduce{remove} a line test in a window of a browser. In general, we would not insert a code into what script of the application test.asp, the result will be same.


Object Application gives developers two methods:

?         Method Lock

?         Method Unlock

?         

?         


They are intended for blocking and razblokirovanija, accordingly, the application. For example, to avoid a situation when in a variable of a level of the application two values enter the name simultaneously, it is possible to apply the following code:

<%

Application. Lock

Application ("MyVar") =someValue

Application. Unlock

%>



Except for collections and properties object Application has two events: Application_OnEnd and Application_OnStart which we shall consider hardly later.

Object Session


This object is intended for management of sessions. He has four properties:

?         CodePage

?         LCID

?         SessionID

?         TimeOut


First two properties is a table of the coding and the identifier lokali. We shall not consider{examine} them, as they practically are not used.


Property SessionID is accessible in a mode « only to reading » and returns the unique identifier of a session. Use:

<%

Response. Write Session. SessionID

%>



Property TimeOut is responsible for time through which cursor ASP will interrupt a session and will remove all information connected to it  on the server. Installation of this property does not allow to leave the data on the concrete user on the server after he was disconnected. Accepts values in minutes. For example:

<%

Session. Timeout = 10

%>



Object Session has one method - Abandon which allows to interrupt compulsorily a session before the expiry of the term specified in property TimeOut. An example of use:

<% Session. Abandon of %>



In object Session, as well as in object Application, it is possible to store{keep} the data. For this purpose variables of a level of session are used. For example:

<% Session ("Username") = "petya" %>



Besides object Session gives developers two events: Session_OnStart and Session_OnEnd which we shall consider little bit below.

File Global.asa


With what begins … no, not the Native land:-) - the web-application? The answer such: from file Global.asa. He is the main file of the application. In this file there can be only following elements:

?         Four events: Application_OnStart, Application_OnEnd, Session_OnStart, Session_OnEnd;

?         Tags <OBJECT> which are applied to creation of copies of ActiveX-components.

?         Special meta-tags which are applied to connection of library of types of DLL-components.


The note: file Global.asa not necessarily should be present at the application but if he is involved by all means should be one on the application.


So, we shall consider events which can is in a file global.asa.


They arise approximately in such order:

?         By the first call of any script cursor ASP tries to find a file global.asa radically your web-application, and in him - obrabotchik events Application_OnStart.

?         If such file exists and is obrabotchik events Application_OnStart the code contained in him, is executed.

?         Differently the cursor tries to find obrabotchik events Session_OnStart and to execute a code contained in him.

?         After end of a session there is event Session_OnEnd.


If the developer has changed a file global.asa, and then has saved it  the application finishes job and event Application_OnEnd is caused. In general, this event arises, when the application comes to the end (when there is a restart of the web-server, restart of a computer, etc.).


Creation of copies of ActiveX-components <OBJECT> occurs to the help of a tag as follows:

<OBJECT RUNAT=Server SCOPE=Scope ID=Identifier PROGID = "progID" |CLASSID = "ClassID">

</OBJECT>



Attribute RUNAT always accepts value Server. Attribute SCOPE defines{determines} area of visibility components (Application or Session). ID is an identifier with which help further it will be possible to get access to object. Further you specify PROGID or CLASSID, which are necessary to identify a component.


For example, you want to create a copy of component BrowserCapabilities (he was considered{examined} above) which would be accessible to each session of the application. For this purpose in a file global.asa it is necessary to write about the following code:

<OBJECT RUNAT=Server SCOPE=Session ID=MyBrowser PROGID = "MSWC.BrowserType">

</OBJECT>



After that you get access to properties and methods of the given component from any script of your application the simple reference{manipulation} to variable MyBrowser. For example:

<%

   Response. Write MyBrowser.cookies

%>



Also copies of ActiveX-components can be created with the help of connection of library of types given components. It is done{made} as follows:

<! - METADATA TYPE = "TypeLib"

   FILE = "file"

   UUID = "uuid"

   VERSION = "version"

   LCID = "localeid"

->



Attribute TYPE always accepts value TypeLib. In attribute FILE it is necessary to specify a way to library of types of your component. UUID is a unique identifier of this library. To specify it is possible either FILE, or UUID. VERSION is, naturally, the version components:-). Attribute LCID is responsible for the identifier lokali.


For example, you have library of dynamic configuration MyLib.dll, and it{she} has library of types MyLib.lib. You can connect her  in a file global.asa in such a way:

<!--

METADATA TYPE = "TypeLib"

FILE = "Mylib.lib"

->



Then in any script of the application it is possible to use this component as follows:

<%

Dim MyVar

     Set MyVar = Server. CreateObject (" Mylib. MyClass ")

   …

%>



For today all this.


Successful design!