Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache handlers - first example ??

Status
Not open for further replies.

turnbui

Programmer
Jul 23, 2005
60
GB
Hi,
I'm trying to understand Apache handlers [and CGI's].
The first example of a handler in the documentation at:-

describes how to invoke a CGI for any .html document request. It then goes on to say

"Then the CGI script is responsible for sending the originally requested document (pointed to by the PATH_TRANSLATED environment variable) and making whatever modifications or additions are desired."

My problem is understanding just how this CGI would then send the original document with say a footer added. Is there an Apache API?
Most CGIs I've seen appear to build a page dynamically.

Any help appreciaated.
Ian t
 
I'm not quite sure what you are asking so forgive me if my answer sounds a little stupid. This is why I like php. CGI usually uses html templates to display things. But since you mentioned footers, it makes me think you are talking about server side includes (ssi). These are html pages that contain cgi calls. The server recognizes them as such by the extension .shtml. Does this sound more like what you are talking about or do you want to execute cgi from other than the cgi-bin?

 
Thanks for responding. No, I guess I haven't explained too well.
It seems to me the reason to have a CGI is to build a dynamic content web page outputting HTML tags etc.
I understand this to be the primary purpose of CGI programs.
As I'm no CGI guru I don't know if there is another purpose for a CGI [it still needs to send some form of reply to the client? No?
I suppose there is no reason that a CGI might read a static document and output it but then add some extra dynamic content e.g. a banner at the bottom of the page.

However, in the example in the documentation aboout handlers it states:-

"Then the CGI script is responsible for sending the originally requested document (pointed to by the PATH_TRANSLATED environment variable) "

it appears to be indicating that the CGI would do some other work than building a dynamic web page and afterwards send the originally requested static page. Therefore would it have to read the document and output it via printf statements [as used in a C program or cout in C++ or whatever in PHP or Perl].

Does this make sense?
 
Hi

No. By saying "responsible for sending the originally requested document" they meant there will be no other automated processing after the CGI script finishes its run, so the returned content will be only what the script will output. So the script is the only responsible for providing the requested anything.

But there is no word about what and how it should do. Of course, yes it can send a static files too. For example for a download URL like the following, when the administrator wants to count the downloads :


But as you already know, CGI script's power is in generating dynamic content.

Feherke.
 
OK Thanks for your time on this. Just thought I might be missing something. But no, you've explained it well.
Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top