Apache :: ASP :: CGI
Description: This perl module provides an Active Server Pages port to the Apache HTTP Server with perl as the host scripting language. Active Server Pages is a web application platform that originated with the Microsoft IIS server. Under Apache for both Win32 and Unix, it allows a developer to create dynamic web applications with session management and perl code embedded in static html files.
Keywords: apache,asp,perl,mod_perl,active server pages,web application,session management, scripting,dynamic html,perlscript,unix,win32,winnt,cgi compatible

INTRO
INSTALL
CONFIG
SYNTAX
EVENTS
OBJECTS
SSI
CGI
PERLSCRIPT
FAQ
TUNING
CREDITS
SUPPORT
SITES USING
EXAMPLES
| CGI CGI has been the standard way of deploying web applications long before ASP came along. CGI.pm is a very useful module that aids developers in the building of these applications, and Apache::ASP has been made to be compatible with function calls in CGI.pm. Please see cgi.htm in the ./site/eg directory for a sample ASP script written almost entirely in CGI.
As of version 0.09, use of CGI.pm for both input and output is seemless when working under Apache::ASP. Thus if you would like to port existing cgi scripts over to Apache::ASP, all you need to do is wrap <% %> around the script to get going. This functionality has been implemented so that developers may have the best of both worlds when building their web applications.
Following are some special notes with respect to compatibility with CGI. Use of CGI.pm in any of these ways was made possible through a great amount of work, and is not gauranteed to be portable with other perl ASP implementations, as other ASP implementations will likely be more limited.
Query Object Initialization CGI headers | print()ing CGI File Upload
Query Object Initialization You may create a CGI.pm $query object like so:
    	use CGI;
    	my $query = new CGI;
As of Apache::ASP version 0.09, form input may be read in by CGI.pm upon initialization. Before, Apache::ASP would consume the form input when reading into $Request->Form(), but now form input is cached, and may be used by CGI.pm input routines. CGI headers Not only can you use the CGI.pm $query->header() method to put out headers, but with the CgiHeaders config option set to true, you can also print "Header: value\n", and add similar lines to the top of your script, like:
     Some-Header: Value
     Some-Other: OtherValue

     <html><body> Script body starts here.
Once there are no longer any cgi sytle headers, or the there is a newline, the body of the script begins. So if you just had an asp script like:
        print join(":", %{$Request->QueryString});
You would likely end up with no output, as that line is interpreted as a header because of the semicolon. When doing basic debugging, as long as you start the page with <html> you will avoid this problem. print()ing CGI CGI is notorious for its print() statements, and the functions in CGI.pm usually return strings to print(). You can do this under Apache::ASP, since print just aliases to $Response->Write(). Note that $| has no affect.
    	print $query->header();
    	print $query->start_form();
File Upload CGI.pm is used for implementing reading the input from file upload. You may create the file upload form however you wish, and then the data may be recovered from the file upload by using $Request->Form(). Data from a file upload gets written to a filehandle, that may in turn be read from. The original file name that was uploaded is the name of the file handle.
    	my $filehandle = $Request->Form('file_upload_field_name');
    	print $filehandle; # will get you the file name
    	my $data;
    	while(read($filehandle, $data, 1024)) {
    		# data from the uploaded file read into $data
    	};
Please see the docs on CGI.pm (try perldoc CGI) for more information on this topic, and ./site/eg/file_upload.asp for an example of its use.
Copyright (c) 1998-1999, Joshua Chamas, Chamas Enterprises Inc.