A little experience in developing CGI in C++builder
Source: Internet
Author: User
c++|cgi sweat ing ... This point of view is for beginners, master can not look.
My knowledge of PHP is not deep enough, so sometimes encountered with PHP can not solve the problem of the use of convenient development tools to do CGI, and security and stability is also easy to improve, EXE program is only dozens of KB, speed is still possible, if the DLL, then the speed is very fast.
First, depending on the page request method, there are two ways to get incoming data:
1, if the Post method:
Example: There is a text box named Tname in the submission form
Then in C++builder you should get the following:
ansistring s = request->contentfields->values[ansistring ("Tname")];
Response->content = s;
Response->sendresponse ();
2, if it is a Get method:
Example: URL request: http://localhost/cgi-bin/xxx.exe/reg?abc=123
Then in C++builder you should get the following:
ansistring s = request->queryfields->values[ansistring ("abc")];
Response->content = s;
Response->sendresponse ();
Second, because the compiler is executable code, so the extension is nothing, as long as the executable in the CGI directory can be, for example, I have a CGI file is Prj.exe, the CGI directory set to read-only, executable, can not browse, etc. Then I will change the Prj.exe file to prj.html or prj.cgi can be normal application, security virtually improved some.
Third, the use of C++builder developed CGI can respond to a number of different requests, using the path identification to differentiate, these paths are virtual, not actually exist, only in the current executable, such as:
Http://localhost/cgi-bin/prj.exe/photo?id=1
http://localhost/cgi-bin/prj.exe/document?id=2
...
Can take advantage of this feature, a number of processing work in a CGI, hehe, a small EXE file on the basic of all the work done.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service