Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java CGI vs. Servlets [closed]

Tags:

java

servlets

cgi

What are the main differences between CGI and Java servlets?

like image 682
Jakub Mach Avatar asked Dec 06 '11 14:12

Jakub Mach


People also ask

Is CGI better than servlet?

Servlet is more secure than CGI as it uses Java. The speed, performance and efficiency of the servlet is better than CGI. CGI scripts can be directly processed. On the contrary, the servlet first translates and compile the program then process it.

What are the advantages of servlets over CGI?

Java servlets are more efficient, easier to use, more powerful, more portable, safer, and cheaper than traditional CGI and many alternative CGI-like technologies.

Is CGI still being used?

CGI provides a mechanism for web servers like Apache to exchange data with programming languages such as Perl. CGI is one of the oldest components of internet infrastructure. It's still widely used today, despite having been superseded by newer alternatives.

Is CGI deprecated?

Deprecated since version 3.11: The cgi module is deprecated (see PEP 594 for details and alternatives). Support module for Common Gateway Interface (CGI) scripts. This module defines a number of utilities for use by CGI scripts written in Python.


1 Answers

Servlets are run in one process (HTTP server with additional features, which called Servlet Container) and they exist as long as that process exists.

CGI means every time there's client request, HTTP server creates new instance of process to serve this request. This is performance killer. Additionally, since there's new process per each request, it means CGI can't aggregate data from several requests in memory, as Servlets can, and must resort to external persistent storage (file or DB). This is performance killer as well.

like image 108
Victor Sorokin Avatar answered Sep 18 '22 22:09

Victor Sorokin