You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by B&T <80...@sympatico.ca> on 2000/04/04 07:52:30 UTC

cgi script efficiently invoking another cgi script

Assume you roughly have a one-to-one between scripts and web pages.
How do you write a script to display its own web page or efficiently
invoke another script/page?  Redirect is slow.  Can you exec, i.e.
can a cgi script exec another in it's own place?

For example:
Suppose you write a "login" script/screen in a cgi file, to display
and verify (and possibly redisplay) a web page for login information.
On successful login, you want it to set some cookies and invoke
another script/screen.  A redirect seems extremely inefficient.

I find this situation pops up all over the place.  How do other
people deal with this?  Just redirect?

Re: cgi script efficiently invoking another cgi script

Posted by darren chamberlain <da...@boston.com>.
B&T (80stclair@sympatico.ca) said something to this effect:
> Assume you roughly have a one-to-one between scripts and web pages.
> How do you write a script to display its own web page or efficiently
> invoke another script/page?  Redirect is slow.  Can you exec, i.e.
> can a cgi script exec another in it's own place?
> 
> For example:
> Suppose you write a "login" script/screen in a cgi file, to display
> and verify (and possibly redisplay) a web page for login information.
> On successful login, you want it to set some cookies and invoke
> another script/screen.  A redirect seems extremely inefficient.
> 
> I find this situation pops up all over the place.  How do other
> people deal with this?  Just redirect?

I don't think you can do this in CGI, but when using the mod_perl API, 
you can call $r->internal_redirect( '/target/uri' ). This
is how Apache handles ErrorDocument generation; the URI in the
location box is unchanged, there is no second request (as far
as the browser is concerned), and the output of the second
handler gets sent to the browser.

darren


-- 
There is nothing so easy but that it becomes difficult when you do it
reluctantly.
		-- Publius Terentius Afer (Terence)