What is Servlet?

Servlet Overview

Earlier Common Gateway Interface (CGI) server-side scripts used to generate dynamic content.

Disadvantages of CGI

  • Platform dependence
  • Lack of scalability
  • Always a new process should be created to serve a request. i.e. f there are simultaneous requests to the same CGI program, the code for the CGI program is loaded into memory N times.
  • Not secure
  • Expensive, to support this need to purchase proprietary package.

Applets created, but focused on client side only to create web applications, Java Servlets will overcome all these limitations and resides on server side to generate dynamic web page.

What is Servlet ?

Java Servlets are part of the Java Enterprise Edition, is a web component deployed on the server side and is used to create Web Application.

Servlets handles multiple simultaneous requests by creating multiple threads. Will see the same with this simple diagram

CGI Java Servlets

CGI Vs Java Servlets

Advantages of Servlets

  • Portable: Servlets are written in Java, so platform independent
  • Works on any OS
  • Better Performance: Multi threaded and efficient
  • Web servers support. Sun Micro systems supplied the Servlet API to all the vendors to develop Web servers that execute Servlets.
  • Inter Servlet communication.
  • Secure  as they are executed within JVM.
  • Powerful, Inexpensive, Convenient to use as it has inbuilt support for HTTP headers, cookies management, session management, Exception handling, Garbage collection etc
  • Supports almost all frameworks like Struts, Spring etc.

One thought on “What is Servlet?

  1. I wish to show thanks to you for bailing me out of this trouble.As a result of checking in the net and meeting techniques were not productive and i thought my life was done.

Leave a Reply

Your email address will not be published. Required fields are marked *