 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 25th, 2003, 03:40 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how to call application variable in global.asa
Hi
Please help
I don't understand why I could not get the value which I defined in global.asa file.
here is my global.asa file
<OBJECT RUNAT=Server SCOPE=Session ID=MyInfo PROGID="MSWC.MyInfo">
</OBJECT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
Application("BldgRootFolderPath")="http://"&<% =Request.ServerVariables(SERVER_NAME) %>&"/bldg/"
End Sub
Sub Application_OnEnd
Application("BldgRootFolderPath")=""
End Sub
And in my .asp file I called different ways, but I could not get the value
<% Application("BldgRootFolderPath") %>
<% Application(BldgRootFolderPath) %>
<% =Application(BldgRootFolderPath) %>
<% =BldgRootFolderPath %>
|
|

July 25th, 2003, 04:42 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
The problem may be caused by the fact that the Application has a scope for the entire application, while the Request is related to an individual user / request.
When the app starts, I guess there is no such thing as Request.ServerVariables......
HtH
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

July 25th, 2003, 04:54 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
when I try to change my application value to 1 I still could not be able to retrieve the value
here is my global.asa file
<OBJECT RUNAT=Server SCOPE=Session ID=MyInfo PROGID="MSWC.MyInfo">
</OBJECT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
Application("BldgRootFolderPath")=1
End Sub
And in my .asp file I called different ways, but I could not get the value
<% Application("BldgRootFolderPath") %>
<% Application(BldgRootFolderPath) %>
<% =Application(BldgRootFolderPath) %>
<% =BldgRootFolderPath %>
|
|

July 25th, 2003, 05:09 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Right, I see.
Here's what's wrong with the stuff you tried:
<% Application("BldgRootFolderPath") %>
This is the correct way to retrieve the value, but you are not outputting it.
<% =Application(BldgRootFolderPath) %>
This is the correct way to output it, but you are not really retrieving it. BldgRootFolderPath is a local variable, and not the name of the App variable.
Mix the two:
<% =Application("BldgRootFolderPath") %>
and it should work.
Tip of the day: Add this to the top of every ASP page you create:
<% Option Explicit %>
This forces you to declare your variables, so you could have caught the problem with BldgRootFolderPath.
HtH
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

July 28th, 2003, 11:28 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
Thanks it works!!
:)
|
|
 |