----- Original Message -----
From: Vijayendra M Agrawal <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 18, 1999 6:33 AM
Subject: Servlet Vs CGI (both in Java)


> Hi,
>
> My project is using CGI in Java. I want to know the
> advantages/disadvantages, if I try to use Servlets instead of CGI.
>
> I have worked with Servlets, and I know the basic functionality of
Servlet.
> I want to prove that Servlets are much better than CGI. If my project had
> been using some other language instead of Java, I could have gathered many
> advantages, which Java as a language provides, but here, the whole thing
> lies in the comparison between Servlets and CGI.
>
> Any help will be appeciated.
>
> Thanks in advance.
>
> Vijay
>
Hi Vijay,

there are no advantages to using Java for CGI. Each CGI script is run as a
separate process. This means
that a Java CGI script would cause a new VM instance to be loaded (slow) and
a new instance of the Java
app that acts as the script (slow).

Servlets are loaded once and once only (you can preload servlets as well).
The instance of the servlet is used
to service http requests in a multi-threaded environment. This has a big
benefit in terms of the amount of resources
requiref to run a servlet compared to a CGI script. The downside is that you
have to make sure that resources like
files, database connections and so on are all used in a thread safe
environment. This adds complexity to your servlets.
However this extra complexity does not outweigh the benefits that servlets
can provide.

All told Servlets are about as good as it gets for efficiency overall
(dependent on the code of course). I am not saying
that Servlets are the best or only thing you can use to create web
applications but CGI scripts do not compete.

Hope this helps

Andy Bailey

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to