JavaDeploy
SiteMap
Perl 1
Perl 2
ASP
XML
Building WebApps
«Prev
Intro ASP
Active Server Pages
Server Side Scripting
Script Syntax
Constants Variables
Arithmetic Operators
Decision Statement
Builtin Functions
Response Write
Three Parts
ASP Object Model
Methods Write Scripts
Project Interactive Message
Server Side Conclusion
Browser Server Dialog
Browser Server Communication
Request Query String
ASP Request Cookies
ASP Response Object
Customizing User Experience
Advertisement Rotation
Building Webapps
Running ASP Web Application
Running Managing ASP App
Using Global Asa File
App Level Variables
Variables Race Condition
File System Object
Writing Text File
Reading Outputting Files
Write Session Variables
ASP Web App Structure
Timing Challenge with Shared Application Variable in ASP
1) Our website is using an application variable to track the current number of users accessing the site at any time. This variable is increased or decreased in value as part of the Session_OnStart and Session_OnEnd procedures.
Currently there are five users.
2) New user Alice arrives at the site, and a new session is created for her. The Session_OnStart procedure for Alice begins by getting the current value of the Application variable, NumCurrUsers, which is 5. The procedure will then add 1 and update the variable.
3) However, before the procedure can update the counter variable, user Betty arrives at the site. The same Session_OnStart procedure is begun for Betty, and it retrieves the current value of the Application variable, which is still at 5.
4) Alice's Session_OnStart procedure completes itself by adding 1 to the value copied from the variable (5), and stores the sum (5+1 = 6) back into the Application variable NumCurrUsers.
5) Then Betty's Session_OnStart procedure completes itself by adding 1 to the value copied from the variable (Also 5, because it had not yet been updated for Alice), and stores the sum (5+1 = 6) back into the Application variable NumCurrUsers.
6) We started with 5 users and added 2 more users, but our NumCurrUsers variable is showing a total of 6 users. Our procedure is correct, but an error has been caused by a second occurrence of the procedure beginning before the first was completed.