---
title: "how much differ servlet from cgi?"  
description: "how much differ servlet from cgi?"  
author: "Rajesh Goswami"  
published: 2010-11-10  
updated: 2011-05-20  
canonical: https://www.mindstick.com/forum/88/how-much-differ-servlet-from-cgi  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# how much differ servlet from cgi?

which types of benifits come in servlet [instead of](https://www.mindstick.com/articles/330/triggers-in-sql-server) [cgi](https://yourviews.mindstick.com/story/2737/what-is-cgi)?

## Replies

### Reply by Anonymous User

Servlets have a number of advantages over CGI and other API's. They are:

1. **Platform Independence**\ Servlets are written entirely in java so these are platform independent. Servlets can run on any Servlet enabled web server. For example if you develop an web application in windows machine running Java web server, you can easily run the same on apache web server (if Apache Serve is installed) without modification or compilation of code. Platform independency of servlets provide a great advantages over alternatives of servlets.
2. **Performance**\ Due to interpreted nature of java, programs written in java are slow. But the java servlets runs very fast. These are due to the way servlets run on web server. For any program initialization takes significant amount of time. But in case of servlets initialization takes place first time it receives a request and remains in memory till times out or server shut downs. After servlet is loaded, to handle a new request it simply creates a new thread and runs service method of servlet. In comparison to traditional CGI scripts which creates a new process to serve the request.
3. **Extensibility**\ Java Servlets are developed in java which is robust, well-designed and object oriented language which can be extended or polymorphed into new objects. So the java servlets take all these advantages and can be extended from existing class to provide the ideal solutions.
4. **Safety**\ Java provides very good safety features like memory management, exception handling etc. Servlets inherits all these features and emerged as a very powerful web server extension.
5. **Secure**\ Servlets are server side components, so it inherits the security provided by the web server. Servlets are also benefited with Java Security Manager.


---

Original Source: https://www.mindstick.com/forum/88/how-much-differ-servlet-from-cgi

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
