CGI Programming

I will use
http://www.gnu.org/software/cgicc/
in the following tutorial.

= HTML Generation =

There is a simple trick using classes constructor and destructor to
generate well-formed code:

 {
 Html h;
 {
 	Body b;
 	cout << "Hello World" << endl;
 } // end of body object
 } // end of html object

It guarantees you not to forget any enclosing tags and the scoping fits
well for C++ Code.

However, cgicc uses a state based approach which makes you independent of
blocks, but you need to be aware to have an even number of boolean elements.
Knowing that the use is straight-forward:

 cout << html() << body() << "Hello World" << body() << html() << endl;

But it gets more nice and comfortable when passing an HTMLElement in the
constructor:

 cout << html(body("Hello World")) << endl;

= QueryString =

The tutorials deal long with parsing form data, but they do not explain
how to deal with QueryString.

The QueryString is parsed by the Cgicc Object too and the Elements are
available.

Having the query string:

 test.cgi?action=4&test=sers

with the code:

 	form_iterator name = cgi.getElement("action");
 	while (name != cgi.getElements().end()) {
 		cout << p() << "name: " << name->getName() << " value: " << **name << p() << endl;
 		name++;
 	}

the output will be something like:

 name: action value: 4
 name: test value: sers

Of course you can also use getIntegerValue and so in of FormEntry, but a lexical_cast is from the
string is also possible. While name->getIntegerValue() silently passes 0, lexical_cast throws
an exception, which should be done because no more useful processing can be done in most cases.

References:
http://velociraptor.mni.fh-giessen.de/Programmierung/anleitung-html.pdf
http://www.yolinux.com/TUTORIALS/LinuxTutorialC++CGI.html
http://c-programming.suite101.com/article.cfm/ajax_and_the_c_programmer
http://www.cs.nyu.edu/courses/spring07/V22.0474-001/lec/cgicc.ps

CGI Specification:
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html

CGI Programming FAQ:
http://www.webthing.com/tutorials/cgifaq.html

fastcgi:
http://cryp.to/publications/fastcgi/
Die Jän 3 15:01:52 CET 2017
anybrowser.gif elektra.jpg fsfe-logo.png patent_button.gif valid-css.png valid-html401.png vim.gif