Print Page | Close Window

server.execute?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=16149
Printed Date: 29 March 2026 at 6:48pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: server.execute?
Posted By: longcall911
Subject: server.execute?
Date Posted: 08 August 2005 at 4:28pm
Although I've been doing some very basic (no pun intended) scripting with asp for a while now, I've never tried the server.execute command before.
 
I recently moved all my DSN connections into external files where they will be easier to change when I switch to a MySql db.
 
I then replaced the on-page connection code with HTML include directives for the appropriate external file for that connection.  That of course forces the server to exit the script engine, process the html, and return to scripting.
 
I've now realized that server.execute is supposed to transfer to the file in the argument, run that code, and transfer back to the origination point.  I have tried using something like server.execute("myIncludeFile.asp") but code in the target file is not running.
 
I can server.transfer("myIncludeFile.asp") and target code runs fine.  But of course, that's just half of what I'm trying to do.
 
Any help with what I'm doing wrong is appreciated.
 
/*tom*/


-------------
make your meetings interactive with an http://www.comtec-ars.com" rel="nofollow - Audience Response System



Replies:
Posted By: dpyers
Date Posted: 08 August 2005 at 6:29pm
If server.transfer works, server.execute should. Can't call it with any query string though although the query string parameters in the container script are available to it and not to server.transfer (or is it the other way around ?).

Try putting a response.write "XXXXX" at the beginning of myIncludeFile.asp just to confirm that the execute is not getting there.


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: longcall911
Date Posted: 15 September 2005 at 10:27pm
I finally got back to this issue and tried a response.write as suggested.  Yep, it works, although not completely as I had expected.
 
The problem is that if a assign a value to a variable in the second file and try to use the variable in the first file once control is returned, the variable is empty.
 
I was expecting that the code in the second page would be treated exactly as though it existed in the first page.  Rather, it behaves like a sub with variables being local even if they are declared in the first page (equivalent of global).
 
So server.transfer is less functional to me than I thought it would be, but still worth using in a number of situations.
 
Thanks, for the help....
 
/*tom*/
 
 


-------------
make your meetings interactive with an http://www.comtec-ars.com" rel="nofollow - Audience Response System


Posted By: dpyers
Date Posted: 15 September 2005 at 11:12pm
Server.Transfer and Server.Execute run in a new separate memory space. Variables declared in the original memory space are not available to them. In the case of Server.Transfer, the original memory space is in fact wiped out.

If I remember right though, Server.Execute passes access to the request object of the original script. For example...

Suppose A.asp Server.Executes B.asp
If you execute A.asp through a post or query (A.asp?X=123) then B.asp also has access to the value of X - Request("X")



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: longcall911
Date Posted: 17 September 2005 at 2:46pm
I have tried and found that yes, request objects (form and quesrystring in particular) are available on the executed page.
 
This makes server.execute a bit more useful to what I'm doing with it.
 
Thanks again, dpyers.
 
/*tom*/


-------------
make your meetings interactive with an http://www.comtec-ars.com" rel="nofollow - Audience Response System



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net