CGI : Java Glossary

go to home page C words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish by Roedy Green ©1996-2009 Canadian Mind Products
index page for letter ⇒ punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
CGI
Common Gateway Interface. A non-Java technique of sending data from HTML forms in browsers to server programs written in C, Python, Tcl or Perl. They typically do data base searches or process the data in HTML forms and send back MIME. Java can simulate the form on the client side, or replace the C with servlets on the server side. There are hundreds of tutorials, but focus on using Perl write server code with no real understanding of how it all works. I found one great tutorial suite that explains what is really going on, which is much more helpful for Java or C programmers at The Complete Webmaster.
book cover recommend book⇒Core Web Programming, Second Edition
 paperback
ISBN13:978-0-13-089793-0clickcounter
ISBN10:0-13-089793-0clickcounter
publisher:Prentice Hall
published:2001-06-03
by:Marty Hall and Gary Cornell
1250 pages. This is a great doorstop of a book. It has a few chapters on client-server programming in Java, and a section of that is on CGI. I have looked at hundreds of Java books and found nothing that deals in depth with client side Java talking to CGI, except Marty’s book. It is really very simple and he does an excellent job of explaining it. Marty has posted all the source code examples from the book for anyone to use. These contain updates and errata fixes you don’t get on the CD-ROM that comes with the book.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca . Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com abe books anz Australian flag

book cover recommend book⇒Core Servlets and Java Server Pages
 paperback
ISBN13:978-0-13-089340-6clickcounter
ISBN10:0-13-089340-4clickcounter
publisher:Prentice Hall
published:2000-05-26
by:Marty Hall
Complete text of the book available on line in pdf format.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca . Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com abe books anz Australian flag

book cover recommend book⇒Core Servlets and Java Server Pages
 paperback
ISBN13:978-0-13-067614-6clickcounter
ISBN10:0-13-067614-4clickcounter
publisher:Pearson Education
published:2001-12-26
by:Marty Hall
Complete text of the book available on line in pdf format.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca . Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com abe books anz Australian flag

GET and POST are two ways to request information from a server. In GET all the request information is contained tacked onto the URL (which can thus be made part of a bookmark). In PUT it is contained in a separate trailing message. GET is idempotent, a mathematician’s word meaning "gives identical results with identical input and has no side effects". Thus if you do a second identical GET, the results can be fished out of cache, without reprocessing the request. In contrast, a POST is assumed to have side effects, or to produce different results each time it is invoked. It has some lasting effect on the world, e.g. submitting a membership application. The request has to be reprocessed from scratch.

The Cyberspyder people make a free tool to help you understand what browsers and servers send back and forth to each other called Webbug. It lets you compose GET commands and see the results. Unfortunately, it does not let you snoop on what browsers and servers are sending to each other.

Forms

When you fill in a form and hit submit, a message sent from your browser (or program simulating a browser) to the server looks like this:
POST actionscript HTTP/1.0
Referer: http://mindprod.com/test.html
Content-type: application/x-www-form-urlencoded
Accept: */*
User-Agent: Mozilla/2.0 (compatible; MSIE 3.01; Windows 95)
Content-Length: 1234
date=03%2F05%2F26&date_fmt=yymmdd
You can send such a message at the low level with Socket.getOutputStream() and read the respond with Socket.getInputStream(), or more commonly at a higher level with HttpURLConnection. See the file I/O amanuensis for details.

When you use the GET protcol the parameters are tacked on the end of the URL, separated-by a ?.

Beware of using raw Sockets for get and put for long messages. Responses come in blocks with a length field on the front. You have to bypass these. They will show up as something like 2000 cr lf in the middle of your data.

POST and GET are not efficient ways for transmitting large volumes of binary data. For that you would set up a separate socket connection.

Bignose Bird has some CGI scripts in Perl you can cannibalise. It also has some tutorials that introduce you to Perl
CGI spec
cookie
echo server
File I/O Amanuensis has sample code to do CGI in Java in the client
HTML Forms
HTTP
HTTP Client
MIME
remote file access
screen scraping
servlet
sniffer
URLConnection
W3C
Webbug

CMP homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.62] The information on this page is for non-military use only.
You are visitor number 13,882. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/cgi.html J:\mindprod\jgloss\cgi.html