The second part, the concept of CGI program design
1.0, CGI program function:
First, what is the public Internet access (CGI)? CGI is a fixed
The standard of communication between the Web server and the external order, enabling the external level
It can be generated to HTML, image or other content, and the part of the serviceman is related to those
Non-outer junctional html, image or otherwise the content of his content is
. Therefore, the CGI program does not allow you to be able to generate a static content, and
Inclusion. The original use of CGI is that it is a definition and widely supported
Spectancy. Although Java, ActiveX, etc. can be completed in CGI program, but
Not all views are supported. In the opposite, all views have supported CGI,
Such as: Lynx, IE, Netscape, etc.
However, with other technologies, CGI also has its locality. I will talk about this section.
The function, advantages and instext of the CGI program.
1.1, CGI function
There is a lot of tasks, CGI is the best is the only choice, these tasks can be divided
Three categories: primary tasks, medium-level tasks and high-level tasks. The initial task is a little
How to use the program, such as:
Text type counter
Subject to simple HTML program
Less than 50 lines with perl language, shell script, C language or C language programming
This kind of task is used to write at least three good people: first, CGI is the most
Fast, and Java, etc. are too large; second, CGI standards are the most compatible when the front browser is
This has been mentioned in front of the front; third, CGI resources are rich, you can be on the Internet
Take a thousands of CGI code.
Medium-level task is to include image images and other slightly complex programming
. In the medium-level task, the difficulty of writing the program is different from CGI and Java.
Not large.
Such tasks include:
Image image icon
HTML of the whole page HTML CGI script
Draw
It is very characteristic, for high-level tasks, using CGI compared to Java programming
Much more. Such a task is:
Back-end data library
search engine
Multi-dynamic page
Among them, the rear-end data library operation (the application of the data library) is now
The superiority of CGI. CGI has a historic history, and there are many useful functions in it.
CGI's library is made by others; at the same time, many companies have provided CGI.
Tong 涫 菘 獾 獾 椒 6 琂 AVA is a programming language, and CGI is the function of the network level. If Java has a large change, you have to write the entire process.
Preface; CGI has a large change, you only want to upgrade the CGI library program.
However, CGI is still subjective in some aspects.
1.2, CGI's limitations
In the image map and the moving, the CGI program is not as good as the Java program.
The more the Java is getting more, the CGI program is, the more it is more and more compromise.
The program and the data library application procedure.
1.3, CGI programming function
The maximum character of the CGI program is to use any one of the words, can be operated
On any of the platform, only it can be in accordance with the specification of CGI. The next table is one
Comparison: task
CGI HTML
HTML
Processing form
YES
NO
Create a non-static content on the web page
YES
NO
Processing image image text
YES
YES
Search in the web page and documentation
YES
NO
Create a form
YES
YES
Creating a platform with unclear
YES
YES
Create a chattering process
YES
NO
Page moving
YES
NO
Page-in-use household file cutting
YES
NO
Next, we use a series of "Hello World" program end:
Perl:
Require "CGI-LIB.PL";
Print & Printheader;
Print "/ n";
Print "Hello WORLD / N";
Print & PrintenV;
EXIT;
This file is stored in a C: / HTTPD / CGI-BIN directory, and the file is named 2_1.pl. In
Use the address in the browser
Http://localhost/cgi-bin/2_1.pl is called. Note, this time
Omnihttpd should be running. If you do it, you can see it in your browser. "
Hello world "and environmental variables.
C: #include
#include "html-lib.h"
#include "cgi-lib.h"
int main ()
{
HTML_HEADER ();
HTML_BEGIN ("Test CGI");
H1 ("cgi program");
Printf ("
-------------------------------------------------- ----------------------------
-
/ N ");
H2 ("CGI Environment Variables");
Print_cgi_env ();
HTML_END ();
Return 0;}
After edding, the file is copied to C: / httpd / cgi-bin, and the name is
2_1.cgi, with address