permaculture playing cards
The moose likes Servlets and the fly likes java servlets  Vs  CGI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "java servlets  Vs  CGI" Watch "java servlets  Vs  CGI" New topic

java servlets Vs CGI

Sandy Schneider

Joined: Mar 14, 2002
Posts: 22
I am new to Java and web development. So I am not experience in either Java servlets or CGI.
I would like to know the advantages and disadvantages on using java servlets vs a CGI to do a post for a request and reply from a URL.
With a CGI you do not need a web server running like Websphere. So what are the advantages on using java servlets?
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Hi sandy, Marty Hall has a good discussion on this topic.
Khurram Shahood(SCJP2)

Joined: Jun 08, 2002
Posts: 18
hi sandy
basically servlets are the server side components of java and uses the all feature of OOP.And CGI is slower as compare to servlets b/c CGI creates each process for each request even servlet just
create a small fragment of process for each request using the feature of multithreading of java.
Thats the main diff b/w these two.

khurram shahood(Java Farmer)
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

"Khurram Shahood(SCJP2)",
Your name does not comly with the JavaRanch naming policy described at
The 'SCJP2' part is unnecessary. Please remove it since it would be unfortunate if your account was locked because of this.
You can edit your profile here.
Sandy Schneider

Joined: Mar 14, 2002
Posts: 22
Do you need a web server to process a CGI like a servlet?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
CGI needs to have some kind of process on the server side. In early days this might be a web server that recognized the CGI url and ran a Perl script. Some ISP allow you to run CGI Perl scripts.
Naturally us Java types run a Java servlet capable web server.
Incidently, servlets and JSP use exactly the same interface as "CGI" so I really don't think there should be a distinction.
I agree. Here's the link:
subject: java servlets Vs CGI
jQuery in Action, 3rd edition