• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between servlet and httpservlet

 
Amol Umrani
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one tell me what is the exact difference between servlet and httpservlet?
I am getting confused on those.
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet is a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP, the HyperText Transfer Protocol.

To write this servlet you have to implement Servlet interface

To implement this interface, you can write a generic servlet that extends javax.servlet.GenericServlet or an HTTP servlet that extends javax.servlet.http.HttpServlet.

generic servlet :- Defines a generic, protocol-independent servlet


Http servlet :- protocol specific servlet
 
Phil Kurian
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To extend on what Gaurav said,

A javax.servlet.Servlet is the basic interface for writing Servlets.

javax.servlet.GenericServlet is an implementation of this interface.

javax.servlet.http.HttpServlet is a sub-interface of javax.servlet.Servlet. It adds a few http specific methods such as doGet, doPost.

Also, an additional service method has been added which recieves a HttpServlet Request and HttpServletResponse. This method examines the request and determines its form (i.e. get post head etc) and calls the relevant http servlet method (i.e. doGet, doPost etc).

Similar to what Gaurav said. A http servlet is just a servlet with some added functionality for use with the http protocol.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic