Hello Gurus,
 
How to access a scalar variable in *.asp file, which declared in global.asa file?
Though it is declared as use vars($title) in global.asa, unable access the $title variable in *.asp file.
 
So, I tried to put in $Application{'title'} = "This is my 1st Apache::ASP project"; in global.asa
and tried to print in *.asp file.
Neither giving error nor value. printing blank in asp page.
 
How to declare a standalone variable in global.asa and access it from *.asp file?
How to declare a $Application{'my_var'} = "something"; and how to access it from *.asp file? 
 
Here is my efforts:
 
I have declared variable $title in global.asa
and when I tried to access http://192.168.1.235/aps/1.asp
 
I am getting error page.
 
 
>>>>>>>>>> global.asa    >>>>>>>>>>>
$MLDBM::RemoveTaint = 1;
use vars qw($title);
 
use File::Basename qw(basename);
 
# when PerlSetVar UseStrict setting on, need to declare
# global variables with "use vars"
 
sub Session_OnStart {
        $Session->{Count} = 10;
        $Session->{onstart} = time();
        $Application->{'Session'.$Session->SessionID} = '?';
        $Response->AppendToLog("Session_OnStart! global.asa ". $Session->SessionID);
        $Application->{'title'} = "FLSoft ltd.,";
}
 
sub Session_OnEnd {
        my $t_session_active = time() - $Session->{onstart};
        $Application->{'Session'.$Session->SessionID} = $t_session_active;
        $Response->AppendToLog("Session_OnEnd! in global.asa ". $Session->SessionID);
}
 
sub Application_OnStart {
        $Response->AppendToLog("Application_OnStart! global.asa");
        $Application->{Count} = 20;
        $title = "FrontlineSoft limited";
}
 
sub Application_OnEnd {
        $Response->AppendToLog("Application_OnEnd! in global.asa");
}
 
sub Script_OnStart {
    $Response->Debug("Script_OnStart $0 in global.asa");
    $Session->{Started}++;
}
sub Script_OnEnd {
    $Response->Debug("Script_OnEnd $0 in global.asa");
    $Session->{Ended}++;
}
 
 
>>>     1.asp >>>>>>>>
 
<!-- sample here -->
<html>
<head>
<title><%=$title%></title>
</head>
<body>
For loop incrementing font size: <p>
<% #use Apache::DBI  %>
<% for(1..5) { %>
<!-- iterated html text -->
<font size="<%=$_%>" > Size = <%=$_%> </font> <br>
<% } %>
<br> title : <%=$title%>
<br>Session id: <%=$Session->SessionID %>
<br> $Application->{Count} : <%=$Application->{Count}%>
<br> $Application->{'title'}: <%=$Application->{'title'}%>
</body>
</html>
<!-- end sample here -->
 
 
Thanks in advance.
 
-SubbaReddy

Reply via email to