Unknown

Introduction to Servlet

Introduction to Servlet

Servlet Technology is used to create web applications. Servlet technology uses Java language to create web applications.
Web applications are helper applications that resides at web server and build dynamic web pages. A dynamic page could be anything like a page that randomly chooses picture to display or even a page that displays the current time.
web application example
As Servlet Technology uses Java, web applications made using Servlet are SecuredScalable and Robust.

CGI (Common Gateway Interface)

Before Servlets, CGI(Common Gateway Interface) programming was used to create web applications. Here's how a CGI program works :
  • User clicks a link that has URL to a dynamic page instead of a static page.
  • The URL decides which CGI program to execute.
  • Web Servers run the CGI program in seperate OS shell. The shell includes OS enviroment and the process to execute code of the CGI program.
  • The CGI response is sent back to the Web Server, which wraps the response in an HTTP response and send it back to the web browser.
How Web Applications with CGI works

Drawbacks of CGI programs

  • High resposne time because CGI programs execute in their own OS shell.
  • CGI is not scalable.
  • CGI programs are not always secure or object-oriented.
  • It is Platform dependent.
Because of these disadvantages, developers started looking for better CGI solutions. And then Sun Microsystems developed Servlet as a solution over traditional CGI technology.

Advantages of using Servlets

  • Less response time because each request runs in a separate thread.
  • Servlets are scalable.
  • Servlets are robust and object oriented.
  • Servlets are platform independent.
How Servlet works