File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes CGI and Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "CGI and Servlets" Watch "CGI and Servlets" New topic

CGI and Servlets

Vallabhaneni Suresh Kumar
Ranch Hand

Joined: Mar 01, 2004
Posts: 68
What are the differences between CGI and Servlets?
What are the advantages of Servlets over CGI?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
I think CGI used to be the name of the standard that governed how form parameters would be transferred within a web server to a further processing step (e.g. a Perl script). In that sense, servlets are an implementation of CGI as well.
If you are actually referring to the invocation of Perl (or whatever) scripts in response to a web request, that entails the startup of a Perl interpreter process for each request, so there'a quite a bit of overhead. More modern variants (called Fast-CGI) somehow keep that process running, and thus have lower overhead.
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
CGI - Common Gateway Interface

The Common Gateway Interface, or CGI, is a standard for external gateway programs to interface with information servers such as HTTP servers.

One of advantages of servlets is using Java language, which could be more powerful and flexible than Perl, PHP or C. Imagine that you want to write enterprise application with Perl. You will have many problems with accessing database, using transactions, using XML, using messaging etc. In Java(J2EE) you have everything ready to use.

SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
I agree. Here's the link:
subject: CGI and Servlets
It's not a secret anymore!