What advantages do servlets have over CGI programs?

Answers were Sorted based on User's Feedback



What advantages do servlets have over CGI programs?..

Answer / guest

Servlets are written in Java and are platform-independent.

Servlets run under the JVM and may be secured using the Java
sandbox.

Servlets run as threads and may be preloaded to improve their
performance.

Is This Answer Correct ?    12 Yes 0 No

What advantages do servlets have over CGI programs?..

Answer / ravikiran

cgi makes use of multiprocessing.Means each and every
request is processed by an individual process.where as
servlets make use of multithreading.A single process with
multiple threads to accomplish the particular task

Is This Answer Correct ?    9 Yes 0 No

What advantages do servlets have over CGI programs?..

Answer / hariom rao

there are two advantages:-
(a)in servlet,it is not necessary to create a seperate
process to handle client request.
(b)servlets are platform independent because they are
written in java.

Is This Answer Correct ?    5 Yes 0 No

What advantages do servlets have over CGI programs?..

Answer / gunasekar

1. Efficient
With traditional CGI, a new process is started for each HTTP request. If the CGI program itself is relatively short, the overhead of starting the process can dominate the execution time. With servlets, the Java virtual machine stays running and handles each request with a lightweight Java thread, not a heavyweight operating system process.

2. Convenient
Servlets have an extensive infrastructure for automatically parsing and decoding HTML form data, reading and setting HTTP headers, handling cookies, tracking sessions, and many other such high-level utilities. In CGI, you have to do much of this yourself.Besides, if you already know the Java programming language, why learn Perl too?

3. Powerful
Servlets support several capabilities that are difficult or impossible to accomplish with regular CGI. Servlets can talk directly to the Web server, whereas regular CGI programs cannot, at least not without using a server-specific API.

4. Portable
Servlets are written in the Java programming language and follow a standard API and thus are portable themselves.

5. Inexpensive
A number of free or very inexpensive Web servers are good for development use or deployment of low- or medium-volume Web sites.This is in contrast to many of the other CGI alternatives,
which require a significant initial investment for the purchase of a proprietary package.

6. Secure
One of the main sources of vulnerabilities in traditional CGI stems from the fact that the programs are often executed by general-purpose operating system shells. So, the CGI programmer must be careful to filter out characters such as backquotes and semicolons that are treated specially by the shell. Implementing this precaution is
harder than one might think, and weaknesses stemming from this problem are constantly being uncovered in widely used CGI libraries.
A second source of problems is the fact that some CGI programs are processed by languages that do not automatically check array or string bounds. Servlets suffer from neither of these problems. Even if a servlet executes a system call (e.g., with Runtime.exec or JNI) to invoke a program on the local operating system, it does not use a shell to do so. And, of course, array bounds checking and other memory protection features are a central part of the Java programming
language.

Is This Answer Correct ?    3 Yes 0 No

What advantages do servlets have over CGI programs?..

Answer / ravikiran.chd

servlets make use of multi threaded programming,where as cgi
is a multi tasking programming

Is This Answer Correct ?    4 Yes 2 No

Post New Answer

More Servlets Interview Questions

What are the methods in HttpSession and their use?

3 Answers  


how can we execute servelt? what the use ".war" or ".jar" file creation

3 Answers   CTS,


Is JSP Thread Safe ???? How To make JSP thrad safe ?????

6 Answers   Cognizant,


How long do servlets last?

1 Answers  


What is the difference between Server and Container?

0 Answers  






What are the annotations used in servlet 3?

0 Answers  


if we know the any consultancies, it will place in company work through consultancy(contract base). please help me I'm 2008 pass out java candidate...

1 Answers  


What is meant by session? Tell me something about httpsession class?

0 Answers  


How are filters?

0 Answers  


How to prevent browser from caching the page content?

1 Answers  


What is servlet tunnelling?

1 Answers  


what is the different between a servlet and a cgi? Why do you go for servlet rather than cgi?

0 Answers  


Categories