Showing posts with label CGI. Show all posts
Showing posts with label CGI. Show all posts

Wednesday, 3 September 2014

Servlets in Java

Servlets in breif 

            A servlet is a Java technology based web component, managed by a container, that generates dynamic content. A servlet can be considered as a tiny Java program which processes user request and generates dynamic content.
Following are the some advantages of using servlets.
(1) They are generally much faster than CGI scripts.
(2) They use a standard API that is supported by many web servers.
(3) They have all the advantages of the Java programming language, including
    ease of development and platform independence.
(4) They can access the large set of APIs available for the Java platform.

What is a Servlet Container?

           Servlet container (also known as servlet engine) is a runtime environment, which implements servlet API and manages life cycle of servlet components.Container is responsible for instantiating, invoking, and destroying servlet components.One example of container is Apache Tomcat which is an opensource container.

Monday, 14 July 2014

Servlets Vs CGI

Servlets Vs 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



Advantages of servlets over CGI
  • Request is run in a separate thread,so faster than CGIs
  • Scalable,can serve many more requests,
  • Robust and Object Oriented.
  • Can be written in Java Programming language.
  • Platform independent.
  • Access to Logging Capabilities.
  • Error handling and Security.

CGI -  
  • CGI creates a new process for each request Whereas Servlet creates a thread for each request and services the request in that thread.
  • For each process created by CGI the process is assinged seperate address space.SO there is memory overload on the server.Whereas for every thread created by the servlet no seperate address space is created all threads operate in the same parent process address space.so there is no memory overlaod.
  • CGI is not based on pooling Whereas servlet are container managed pooled objects.