• September 14, 2014
  • Servlet
  • Comments Off on Servlet architecture overview

Servlet architecture overview

Web application:

A web application or website is an application program which accessed over a network connection using HTTP and often runs inside a web browser.

Web browser:

A web browser is a program which is act as an interface between user and web application e.g. Internet Explorer, Chrome, Safari, Mozilla firefox etc.

CGI (Common gateway interface):

CGI was the first protocol or way of communication between web server and program. It passes a request from a web user to an application program and receives data back to forward to the web user i.e. It is responsible for dynamic content generation.

Advantages of CGI:

  1. 1. Technology portability: CGI programming can be written in variety of languages like c, c++, perl.
  2. 2. Web server portability: All service providers support CGI Programs.

Disadvantages:

  1. 1. Response time is high.
  2. 2. CGI scripts are platform-dependent.
  3. 3. For every request, a new process will be started and web server is limited to start processes.
  4. 4. CGI programs are not object oriented always.

Servlet overcomes the above disadvantages.

Servlet as technology:

As a technology servlet provides a model of communication between a web user request and the application or program on the web server.

Servlet as component:

As a component servlet is a program which is executed in web server and responsible for dynamic content generation.

Main tasks of servlet:

  1. 1. Read the implicit and explicit data sent by web browser.
  2. 2. Generate result by processing the data.
  3. 3. Send the implicit and explicit data as a response to the web browser.

Servlet Packages:

javax.servlet and javax.servlet.http packages contains the classes and interfaces for servlet API. These packages are the standard part of Java’s enterprise edition.

javax.servlet contains a number of classes and interfaces which are mainly used by servlet container.

javax.servlet.http contains a number of classes and interfaces which are mainly used by http protocol.

Differences between CGI and Servlet.

                       CGI                Servlet
  1. 1. CGI is process based. For every request a new process will be started.
  2. 2. Concurrency problems can’t occur in CGI because it is process based.
  3. 3. Platform dependent.
  4. 4. Can be written in variety of languages like c, c++, perl.
  5. 5. Response time is high.
  1. 1. Servlet is thread based. For every request a new thread will be started.
  2. 2. Concurrency problems can occur in servlet because it is thread based.
  3. 3. Platform independent.
  4. 4. Can be written only in java.
  5. 5. Response time is low.

Related topics:

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.

 


Comments are closed.