spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / web / articles / htmlform / comm

Document and Application Communication

Developer News
Cisco Lawsuit: A Test for the GPL?
Shifts for Enterprise Linux, Green Networks in '09
Gifts for All in Linux 2.6.28

Programming with HTML Forms

As mentioned before, when the submit button is clicked, the POST method causes a string to be sent to the application. The string consists of a series of name=value substrings, separated by &'s. An added complication is that name and value are encoded so that spaces are changed into +'s, and some characters are encoded as hexadecimals. Fortunately, form application programmers have written routines for handling these coded strings.

The POST method means that the form application will receive the string on its standard input. This protocol is defined by the Common Gateway Interface (CGI) specification, which also states that an application can respond by generating suitable code on its standard output. Details on the CGI specification can be found at:

The CGI specification permits an application to output many different types of documents (e.g. an image, audio, plain text, HTML, or references to other documents). The application determines the output type by writing a header string to standard output, of the form:

    Content-type: type/subtype

type/subtype must be MIME (Multipurpose Internet Mail Extensions) types; two common ones are text/html for HTML output, and text/plain for ASCII text. There must be a blank line after the header, and then the data can begin. For instance, an application (coded in C) could output the following:

    printf("content-type: text/html\n\n"); /* the newlines are necessary for the blank line */ printf("<html><head><title>Search String Error!</title></head>"); printf("<body><H1>Search String Error!</H1>"); printf("Must specify at least 1 pattern<P>"); printf("</body></html>");

This generates the following output:


Search String Error!

Must specify at least 1 pattern.

Figure 1: HTML created by C code


Further reading on CGI programming:

Comments are welcome

Copyright 1996 Andrew Davison and

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Overview of Popular JavaScript Frameworks - ASP.NET AJAX · An Introduction to 3D · Email Marketing Terms to Know
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Anonymous Dialog Security in SQL Server 2005 Express Service Broker Conversation · OpenVPN: Revoking Access and Expanding Management Options · Connecticut Town Lays Groundwork for Merged School, Municipal VoIP Network

Created: Apr. 26, 1996
Revised: May 7, 1996

URL: http://webreference.com/htmlform/comm.html