Professional Documents
Culture Documents
By
Sindhu.K
Features
Server side java program
Resides in server
Responds to client’s request
Handles multiple requests coming from clients
Client uses HTTP protocol to request the web page
Servlets sends its response in the form of DHTML document
This can be viewed through the browsers where the client is
running
More efficient than CGI (Common Gateway Interface) or
Perl.
Interface Servlets
Methods that help to build servlet are defined here
The methods are:
init()
service()
destroy()
getServletConfig()
getServletInfo()
These are called automatically when a servlet is
executed.
Implementation
Servlet interface is implemented in two
abstract classes
javax.servlet.GenericServlet
Protocol independent
javax.servlet.HttpServlet
Http servlet suitable for web
applications.
HttpServlet Class
Sub class of GenericServlet class.
Methods used:
doGet()
To handle GET request
doPost()
To handle POST request (used when a large amount of data is
to be sent to the server from a client).
Note:
GET requests are cached in the client machine
Method Syntax
Void doGet(HttpServletRequest req,
HttpServletResponse res)