Using the global.jsa File
Each jsp application can have one global.jsa file. (The file name extension jsa stands for JRun
Server Application) This file must be stored in the root directory of the jsp application. The
page compilation engine reads a global.jsa file when:
· The Web server receives the first post-startup request for any jsp file in a given
application; that is, after the Web server starts, the first request for any jsp file in an
application causes page compilation engine to read the global.jsa file for that
application.
· A user who does not have a session requests a jsp file in an application.
You can include the following in a global.jsa file: application-start events, session-start events,
application-end events, and session-end events.
The following example illustrates how to specify each event from within the global.jsa file.
<script runat="server" event="Session_OnStart">
Response.write("Hello This is a new Session<BR>");
System.out.println("Session_OnStart called for: "+Session.getId());
</script>
<script runat="server" event="Session_OnEnd">
System.out.println("Session_OnEnd called for: "+Session.getId());
</script>
<script runat="server" event="Application_OnStart">
System.out.println("Application_OnStart called");
Application.setAttribute("greeting", "hi mom");
</script>
<script runat="server" event="Application_OnEnd">
System.out.println("Application_OnEnd called");
Application.removeAttribute("greeting");
</script>
There are restrictions as to what objects are available within each event handling method.
· Session_OnStart can access any object a “normal” JSP file can
· Session_OnEnd can only access the Application, Session, and Server objects. The
Server object cannot call the MapPath() method. The CallPage() method is also not
available within Session_OnEnd.
· Application_OnStart can only access the Application and Server objects. The
CallPage() method is not available within Application_OnStart.
· Application_OnEnd can only access the Application and Server objects. The
CallPage() method is not available within Application_OnEnd.
: