jwCGI is a C++ library for creating CGI (Common Gateway Interface)
programs. The library comes with several example programs to help you
get acquainted with its usage. If you are familiar with C/C++ it will
be quick to learn. It also incooperates an xhtml class for displaying
web content. If you need some kind of interpreted programming language
(i.e. PHP or Perl) please see the links on the left of this page.
jwCGI is free software subject to the terms of the GPL License.
To use the library, create a basic C++ file as below. In your main
function just instantiate an instance of the CGI object class. One
other caveat, we must close the http header to the browser, calling xhtml::pagebegin(
) accomplishes this for us. At this point any data sent to the xhtml
object gets sent to the requesting browser. Here is code for the
typical hello world programming example but in jwCGI speak.
#include <jwcgi/jwcgi.h> using namespace jwcgi; int main(int argc, char* argv[ ], char *envp[ ]) { CGI cgi; // instantiate our CGI object xhtml<std::ostream> p(std::cout); // encapsulates xhtml output p.pagebegin("Hello World demo"); // call WepPage functions to send html to the browser p.body( ); p.div( ); // keep well formed xhtml p << "Hello World"; p.divend( ); return 0; }
Once we have an instance of CGI we can use its member functions to
extract data sent by browsers to the web server. Of course a form is
needed for the user of the browser to inform us what data to process.
In the case of the simpleform demo program the cgi program is also
called to display this form. It is probably easier to use a program to
specifically write form pages for us (i.e. wysiwyg html page editor).
To make it easier for users of jwCGI to get up and running I have the
demo programs display the forms needed by the CGI. Just compile the
demo programs and browse to them from a web browser. Obviously your web
server will have to have CGI enabled, with the correct file permissions
set on the files for the cgi's to work. There are only a few functions
in the interface to use: