Servlets are modules of Java code that run in a server application to answer client requests. CGI stands for Common Gateway Interface, which is the standard for creating dynamic files or Web pages. The following table depicts the difference between Servlet and CGI:
| Servlet | CGI (Common Gateway Interface) |
|---|---|
| Servlets can link directly to the Web server. | CGI cannot directly link to Web server. |
| Servlets can share data among each other. | CGI does not provide sharing property. |
| Servlets can perform session tracking and caching of previous computations. | CGI cannot perform session tracking and caching of previous computations. |
| Servlets are portable. | CGI is not portable. |
| In Servlets, the Java Virtual Machine stays up, and each request is handled by a lightweight Java thread. | In CGI, each request is handled by a heavyweight operating system process. |
| Servlets automatically parse and decode the HTML form data. | CGI cannot automatically parse and decode the HTML form data. |
| Servlets can read and set HTTP headers, handle cookies, tracking sessions. | CGI cannot read and set HTTP headers, handle cookies, tracking sessions. |
| Servlets is inexpensive than CGI. | CGI is more expensive than Servlets. |
Like this article? Share it with others
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
