CGI : Java Glossary
home C words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
Go to : 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. Common Gateway Interface RFC Project has a CGI spec. It is written in typical academic official spec style. It is intentionally made abstract, vague, and incomprehensible to prove how brilliant the authors are that no one but they can make head nor tail of what it means. Like a typical spec it uses a secret notation instead of examples. However, if you need the language lawyer type details that’s the place to go. I am snarly because I have wasted hours trying to get some very simple questions answered about CGI. That spec is not that much worse than your average language reference document. 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
ISBN10:0-13-089793-0
ISBN13:978-0-13-089793-0
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.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag

book_cover recommend book⇒Core Servlets and Java Server Pages
 paperback
ISBN10:0-13-089340-4
ISBN13:978-0-13-089340-6
publisher:Prentice Hall
published:2000-05-26
by:Marty Hall
Complete text of the book available on line in pdf format.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag
book_cover recommend book⇒Core Servlets and Java Server Pages
 paperback
ISBN10:0-13-067614-4
ISBN13:978-0-13-067614-6
publisher:Pearson Education
published:2001-12-26
by:Marty Hall
Complete text of the book available on line in pdf format.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK 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
cookie
echo server
File I/O Amanuensis has sample code to do CGI 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.18] Spread the Net
You are visitor number 12,081.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/cgi.html J:\mindprod\jgloss\cgi.html