- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between CGI and Servlet
In this post, we will understand the difference between CGI and servlet.
Servlet
It is a Java class that helps extend the abilities of servers.
These are the servers that help host applications, which are accessed using a requestresponse model.
They help extend the applications that are hosted using web servers.
But they also have the ability to respond to other kinds of requests.
For different kinds of applications, HTTP-specific servlet classes can be defined using Java Servlet.
These programs are written in Java, and they run on Java virtual machine.
It is based on thread.
This means that for every new request, a new thread is created.
It is an object oriented concept.
It is portable.
It stays in memory until not explicitly eliminated.
It can use any web-server.
It allows data sharing.
It helps link directly to the server.
It can read and set the HTTP servers.
The process of construction and destroying a thread is not expensive.
CGI (Common Gateway Interface)
It behaves like a middleware between www servers and external database and information resources.
World Wide Web consortium has defined CGI.
It also defines how a program would interact with a HTTP (HyperText Transfer Protocol) server.
The server would pass the information to an application.
This application would process the data, and send a confirmation message stating the same.
This process of passing/communicating the data back and forth between the application and the server is known as CGI.
It is based on a process. This means that for every new request, a new process is created.
It can be implemented in any programming language.
It need not be object oriented.
It doesn’t link the server directly to the application.
It doesn’t have the ability to set or read HTTP server data.
The construction and destruction of processes is considered expensive.
It is not portable.
It is removed from memory once the request has been server.
It uses web-server that it supports.
It doesn’t support data sharing.