Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > how to return value from server.execute call

Reply
Thread Tools

how to return value from server.execute call

 
 
Jim Rodgers
Guest
Posts: n/a
 
      08-05-2007
I am trying to replace a huge chunck of code that currently I incorporate
with an #Include directive. The program rarely has to flow through that
code, so I thought it would be better if I used Server.Execute.

I found I can pass data TO the called asp file by creating an HTML <input>
and erading it after I get there.

However, I also need to read back ONE variable that the called file must
set. I cannot figuer out how to do that. My backup positions are (1) I can
keep on using the #Include technique, and (2) I can use a database to bridge
the gap.

BUT... Isn't there a way to carry data BACK TO the calling asp file FROM
THE CALLED asp file?

I certainly do appreciate the help!

Thanks,

Jim

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      08-05-2007
=?Utf-8?B?SmltIFJvZGdlcnM=?= wrote on 05 aug 2007 in
microsoft.public.inetserver.asp.general:

> I am trying to replace a huge chunck of code that currently I
> incorporate with an #Include directive. The program rarely has to
> flow through that code, so I thought it would be better if I used
> Server.Execute.
>
> I found I can pass data TO the called asp file by creating an HTML
> <input> and erading it after I get there.
>
> However, I also need to read back ONE variable that the called file
> must set. I cannot figuer out how to do that. My backup positions
> are (1) I can keep on using the #Include technique, and (2) I can use
> a database to bridge the gap.
>
> BUT... Isn't there a way to carry data BACK TO the calling asp file
> FROM THE CALLED asp file?


try session variables:

============== test.asp ==================
<%
response.write "running test.asp<br>"
session("a") = "from test"
response.write "1-A: "&session("a")&"<br>==========<br>"

server.execute "testtest.asp"

response.write "running test.asp<br>"
response.write "2-A: "&session("a")&"<br>"
response.write "3-B: "&session("b")&"<br>"
%>
==========================================

============ testtest.asp ================
<%
response.write "running testtest.asp<br>"
session("b") = "from testtest"
response.write "A: "&session("a")&"<br>"
response.write "B: "&session("b")&"<br>==========<br>"
%>
==========================================

===== result from running test.asp ======
running test.asp
1-A: from test
==========
running testtest.asp
A: from test
B: from testtest
==========
running test.asp
2-A: from test
3-B: from testtest
==========================================


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
 
Jim Rodgers
Guest
Posts: n/a
 
      08-05-2007
"Evertjan." wrote:

> =?Utf-8?B?SmltIFJvZGdlcnM=?= wrote on 05 aug 2007 in
> microsoft.public.inetserver.asp.general:
>
> > I am trying to replace a huge chunck of code that currently I
> > incorporate with an #Include directive. The program rarely has to
> > flow through that code, so I thought it would be better if I used
> > Server.Execute.
> >
> > I found I can pass data TO the called asp file by creating an HTML
> > <input> and erading it after I get there.
> >
> > However, I also need to read back ONE variable that the called file
> > must set. I cannot figuer out how to do that. My backup positions
> > are (1) I can keep on using the #Include technique, and (2) I can use
> > a database to bridge the gap.
> >
> > BUT... Isn't there a way to carry data BACK TO the calling asp file
> > FROM THE CALLED asp file?

>
>
> try session variables:
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
>


Thanks, Evertjan. We made a design decision early on in the project not to
use the Session object -- for various reasons, mostly related to scalability
in some way. But you're right, of course; that would be perfect.

This is why I described one of my fallback positions to be using a database,
which is the way many developers implement Session functionality without the
Session object. I believe MS eCommerce Server (correct name?) does it that
way.

It seems, except for the Session object, any "variables" that can be passed
TO the CALLED asp file are essentially read-only in the sense they cannot be
changed and passed back to the CALLING asp file.

For example, I can create Request.Form(1) in the CALLING file using an
<input> element, and I can read it in the CALLED file. However, this
expression is not permitted on the left side of an equation, so it seems I
cannot change that value.

Moreover, if I create yet another Form name / value pair in the CALLED file,
that one will NOT be visible to the CALLING file upon return.

Can you think of any way a script can modify a passed value in the CALLED
file so a script in the CALLING file can see it?
 
Reply With Quote
 
Jim Rodgers
Guest
Posts: n/a
 
      08-05-2007
"Jon Paal [MSMD]" wrote:

> Server.execute is a dynamic include, so any variables defined in the parent file will also be availabel in the "include" file, since
> they execute within the same page scope.
>
> http://support.microsoft.com/kb/224363
>


Thank you, Jon Paal. The variables that are available to the script in the
CALLED file are the ASP object variables like Server, Request, Response,
Application, etc., and most importantly, variables in the Session object.
The VBScript variables do not scope beyond the CALLING file as they do with
the #Include directive. It's very frustrating.

BTW, the article you mentioned has some problems; I think they should pull
it. For example, the data stream to the client includes...

<html>
<body>
<html>
<body>
....
</body>
</html>
</body>
</html>

....which works, but, well they need to do more than just test their examples.

An excellent (albeit somewhat verbose) alternative article is this one:

http://msdn.microsoft.com/msdnmag/issues/0400/redir/

Yet even that one fails to mention (I think) the subject of returning (or
not...) values back to the CALLING script.

Can you think of any other ways?

Thanks,

Jim

 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      08-05-2007
"Jim Rodgers" <> wrote in message
news:63BDC50C-8C05-4B6E-A0F5-...
> I am trying to replace a huge chunck of code that currently I incorporate
> with an #Include directive. The program rarely has to flow through that
> code, so I thought it would be better if I used Server.Execute.
>
> I found I can pass data TO the called asp file by creating an HTML <input>
> and erading it after I get there.
>
> However, I also need to read back ONE variable that the called file must
> set. I cannot figuer out how to do that. My backup positions are (1) I

can
> keep on using the #Include technique, and (2) I can use a database to

bridge
> the gap.
>
> BUT... Isn't there a way to carry data BACK TO the calling asp file FROM
> THE CALLED asp file?
>
> I certainly do appreciate the help!
>


For this scenario the next step from an include file is a VB6 dll. Of
course for various reasons that may not be an option.

For an include file that contains a large set of functions enclosing them in
a class helps to keep the global namespace free.

Server.Execute is not an appropriate solution.

How have you determined that having a large include file is a problem?


--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Jim Rodgers
Guest
Posts: n/a
 
      08-05-2007
"Anthony Jones" wrote:
>
> For this scenario the next step from an include file is a VB6 dll. Of
> course for various reasons that may not be an option.
>
> For an include file that contains a large set of functions enclosing them in
> a class helps to keep the global namespace free.
>
> Server.Execute is not an appropriate solution.
>
> How have you determined that having a large include file is a problem?
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>


Thanks, Anthony!

I have not yet determined that having a large include file is a problem. I
may keep what I have until it is a problem. However, I am not only creating
a specific web application, but I am trying to keep my options open for code
reuse since the project is turning into a decent platform for more work.

Your idea about a VB6 DLL is excellent. I am planning to replace a lot of
my #Includes (containing my VBScript Subs and Functions "library") with a DLL
soon. But it will make more sense to you and everyone if I mention one more
aspect of the problem I have in the current case.

The subject asp file (which currently is #Included and which I would prefer
to be Server.Execute'd) processes a huge number of Request.Form(i) variables
for all kinds of input validation requirements. It is because of the
Request.Form(i) variables that I felt Server.Execute would be a good choice.
I hate having to pass all these TO the CALLED file.

Since no one could tell me about [an obscure] technique for getting one or
two answers back to the CALLING script, I have decided to write the
validation results to a database. Thus, I need only to check the database
when I return to the first file. Previously, I acted on the validation
results (with Response.Write's) in the CALLED file. Now I will simply do
that after I return. Even though the second file now does no output to the
client side, it still makes sense to use Server.Execute because of the sheer
volume of Request.Form(i) variables.

Would you agree?

Thanks again for your remarks.

Jim

 
Reply With Quote
 
Jim Rodgers
Guest
Posts: n/a
 
      08-06-2007
"Jon Paal [MSMD]" wrote:
>
> >
> > Yet even that one fails to mention (I think) the subject of returning (or
> > not...) values back to the CALLING script.
> >
> > Can you think of any other ways?
> >
> > Thanks,
> >
> > Jim
> >

>
> You don't have to "return" them as they are available as part of the parent page scope. Just use the variable.
>



Jon,

When I reference (in the VBScript in the "executed" file) any variable from
the VBScript in the "parent" file, I get a variable not declared error.

When I reference (in the VBScript in the "parent" file) any variable
declared only in the VBScript in the "executed" file, I get a variable not
declared error.

And even though I can "see" variables in the Request.Form collection from
the parent to the executed file, I cannot see any Request.Form items declared
in the executed file. (Although this is perhaps not what you were referring
to.)

I am using "Dim" to declare these variables (and Option Explicit). I
haven't tried "Public" yet, do you think that would work? I can see how it
might. Frankly, I don't think the documentation is very good on this point.

(I am referring to variables declared at what I guess you might call the
"module" level -- that is, I am not referring to any variables declared only
in a VBScript subprogram or function.)

The reason I assumed (as you are also telling me) ...that the scope carried
forward to the executed file, is the statement made in the documentation
(somewhere!) that subs and functions declared in file #Includes in the parent
file are not visible in the executed file. The documentation went on to say
that one must also #Include these same files in the executed file for that
"child" VBScript to see it.

Later, I concluded this is just another example of the bizarre confusion
caused by the ever-deteriorating MSDN documentation (especially, but not
limited to ASP Classic). I further concluded, what they really meant was NO
MATTER HOW these elements (variables, subs, and functions) are declared in
the parent, the executed file simply will not see them. Of course, by
putting copies (re-declaring) of the subs and function in the executed file,
you are back in business. However, this does not imply a remedy for the
scope of VBScript variables.

Or does "Public" work? Jon, do you have any links to clear specs or
examples. I would love to see this settled for sure one way or the other.

Thanks for helping. I appreciate the time you spend help me clear this up.

Cheers,

Jim Rodgers

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-06-2007
=?Utf-8?B?SmltIFJvZGdlcnM=?= wrote on 05 aug 2007 in
microsoft.public.inetserver.asp.general:

> "Evertjan." wrote:
>
>> =?Utf-8?B?SmltIFJvZGdlcnM=?= wrote on 05 aug 2007 in
>> microsoft.public.inetserver.asp.general:
>>
>> > I am trying to replace a huge chunck of code that currently I
>> > incorporate with an #Include directive. The program rarely has to
>> > flow through that code, so I thought it would be better if I used
>> > Server.Execute.
>> >
>> > I found I can pass data TO the called asp file by creating an HTML
>> > <input> and erading it after I get there.
>> >
>> > However, I also need to read back ONE variable that the called file
>> > must set. I cannot figuer out how to do that. My backup positions
>> > are (1) I can keep on using the #Include technique, and (2) I can
>> > use a database to bridge the gap.
>> >
>> > BUT... Isn't there a way to carry data BACK TO the calling asp
>> > file FROM THE CALLED asp file?

>>
>>
>> try session variables:
>>


>
> Thanks, Evertjan. We made a design decision early on in the project
> not to use the Session object -- for various reasons, mostly related
> to scalability in some way. But you're right, of course; that would
> be perfect.
>
> This is why I described one of my fallback positions to be using a
> database, which is the way many developers implement Session
> functionality without the Session object. I believe MS eCommerce
> Server (correct name?) does it that way.


That is duplicating the session object, and if that is done well, the
solution should work the same.

> It seems, except for the Session object, any "variables" that can be
> passed TO the CALLED asp file are essentially read-only in the sense
> they cannot be changed and passed back to the CALLING asp file.


I don't see why not. A "variable" stored in a database should have the
same workings as using the session database structure.

> For example, I can create Request.Form(1) in the CALLING file using an
> <input> element, and I can read it in the CALLED file.


But that is not using a serverside daabase.

> However, this
> expression is not permitted on the left side of an equation, so it
> seems I cannot change that value.


And rightly so.

> Moreover, if I create yet another Form name / value pair in the CALLED
> file, that one will NOT be visible to the CALLING file upon return.
>
> Can you think of any way a script can modify a passed value in the
> CALLED file so a script in the CALLING file can see it?


I personally think you should keep to includes
or change your design decision.

It is never to late to improve on design decisions,
they are only to be kept static at your peril.

In the end:

What is wrong with an include,
where the whole code is contained in:

If Not myBoolean Then
' whole code
End If

as opposed to a statement line

If Not myBoolean Then Server.execute "...."

?


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-06-2007
Jon Paal [MSMD] wrote on 06 aug 2007 in
microsoft.public.inetserver.asp.general:

> my bad, all page scope variables are not handled, see Dave's comment
> below.


Jon, what are you refering to?


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-06-2007
Jon Paal [MSMD] wrote on 06 aug 2007 in
microsoft.public.inetserver.asp.general:

> you are correct..


Jon, what and who are you referring to?


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Mocha raise exception first call, return value second call Raymond O'Connor Ruby 1 03-08-2007 08:38 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
getting return value from function without return statement. Seong-Kook Shin C Programming 1 06-18-2004 08:19 AM
Return a return value from Perl to Javascript PvdK Perl 0 07-24-2003 09:20 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57