Introduction of Servlet
Introduction of Servlet
Servlet is a simple java program that runs on server and capable of handling request and generating
dynamic response for the client.
A web application is an application accessible from the web. A web application is composed of web
components like Servlet, JSP, Filter, etc. and other elements such as HTML, CSS, and JavaScript. The
web components typically execute in Web Server and respond to the HTTP request.
CGI technology enables the web server to call an external program and pass HTTP request
information to the external program to process the request. For each request, it starts a new
process.
Disadvantages of CGI
There are many problems in CGI technology:
If the number of clients increases, it takes more time for sending the response.
For each request, it starts a process, and the web server is limited to start processes.
It uses platform dependent language e.g. C, C++, Perl.
DB
www.technid Server
request
hi.com
Servlet
Chrome
firefox
Response
First of all servlet program will execute on server, so we have to install a server either web server or
application server.
Three methods are servlet life cycle methods and 2 are non-life cycle methods
All five methods has to be overridden by the user defined class or implementing class.
User definedclass
Class MyServlet implements
Servlet
{ SERVER
It is an abstract class.
There are 5 methods in this class too but 4 methods has defined body in this class and we have to
define only one method in user defined class or child class.
User definedclass
Class MyServlet extends
GenricServlet
SERVER
{
To execute user
defined servlet class
with the help of xml
Override 1 methods here file
Mapping servlet in xml file for
Service() the server