What is the difference between GenericServlet and HttpServlet?

GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a client request is made. This means that it gets called by both incoming requests and the HTTP requests are given to the servlet as they are.

Showing Answers 1 - 43 of 43 Answers

Srikanth Baki

  • May 27th, 2005
 

GenericServlet belongs to javax.servlet package 
GenericServlet is an abstract class which extends Object and implements Servlet, ServletConfig and java.io.Serializable interfaces. 
The direct subclass to GenericServlet is HttpServlet.It is a protocol-independent servlet.  
To write a GenericServlet you need abstract service() to be overridden. 
 
 
HttpServlet: 
HttpServlet belongs to javax.servlet.http package 
This is an abstract class which extends GenericServlet and implements java.io.Serializable 
A subclass of HttpServlet must override at least one method of doGet(), doPost(),doPut(), doDelete(), init(), destroy(), getServletInfo()

shyamalatha

  • Sep 12th, 2005
 

Generic servlets works for every protocal and Http servlet works for only Http protocol.

  Was this answer useful?  Yes

gokulakrishnan

  • Sep 19th, 2005
 

GenericServlet is an abstract class it can handle all types of protocols,but HttpServlet handle only Http specific protocols.In generic we use only service method but Http we use doGet() & doPost().but now a days we use only Http becoz WWW depends upon Http PROTOCOLS.

  Was this answer useful?  Yes

Chidambara Gupta. Cheedella

  • Sep 22nd, 2005
 

Basically they 2 differences between GET and POST.

1. In GET method the information is sent through URL and it is visible to everyone where as in POST method the information is sent through the Headers which cant be visible to others.

2. Through GET method we can sent only 2KB of information(coz it will go through URL) where as with POST method we can send unlimited data as the information will be sent through Headers.

3. Generally GET method is used to get the data from the resources and POST method is used to post or store the data into DB.

  Was this answer useful?  Yes

Random

  • Sep 28th, 2005
 

when u invoked a servlet..by typing the name in the addresbar.of the internet expl..it is invoked via post method...but when u invoke it viz form button it is invoked via get method

  Was this answer useful?  Yes

sudhakar

  • Oct 15th, 2005
 

GenericServlets are ment for generic use, where as HttpServelets are specific to Http Protocol only

  Was this answer useful?  Yes

Saffy

  • Oct 16th, 2005
 

The servlet that gets invoked with Common Gateway Interface protocool is known has Genaric Servlet. Limitation: Request Replication.The servlet that is invoked by HTTP protocal is know as HTTP Servlet.Advantage: It don't replicate the request.

  Was this answer useful?  Yes

The servlet that gets invoked with Common Gateway Interface protocool is known has Genaric Servlet. Limitation: Request Replication.The servlet that is invoked by HTTP protocal is know as HTTP Servlet.Advantage: It don't replicate the request.

  Was this answer useful?  Yes

devendar

  • Aug 7th, 2006
 

1.generic srevlet for universalprotocols where as http for http protocols.

2.in generic servlet we have to implement the service method where as in http no need to implement service method.

  Was this answer useful?  Yes

rameshvdnv

  • Apr 25th, 2007
 

Generic Servlet is an abstract class provided by javasoft which is designed in such away that it is not specific to a particular protocol whereas when it comes to HTTPServlet it is designed by javasoft and it is an abstractclass and it is especially designed to deal with HTTP protocols.

  Was this answer useful?  Yes

Ravi Sindhal

  • Aug 15th, 2007
 

1. Generic Servlet are protocol independent but Http Servlet are protocol dependent.

2. Generic Servlet can handles all type of protocols but Http Servlet can handle only http specific protocols.

3. In Generic Servlet we have to implement the service method where as in http Sevlet no need to implement service method.

  Was this answer useful?  Yes

JOE

  • Sep 21st, 2011
 

GenericServlet is superclass to HTTPServlet.
HTTPServlet uses protocols such as get,post.

  Was this answer useful?  Yes

gayathri

  • Nov 30th, 2011
 

Genericservlet is protocol independent, httpservlet is protocol dependent

Genericservlet contains p v service(-,-),
httpservlet contains p v service(-,-), protected v service(-,-), doGet(-,), doPost(-,-), doPut(-,-),--------etc

httpservlet is one of the predefined subclass of genericservlet

  Was this answer useful?  Yes

GenericServlet suppports only service(). It handles simple requests, It is platform-independent. It handles all types of protocols like http, smtp, ftp.

HttpServlet supports both doget() & dopost(). It supports state programming also. It is platform-dependent. It handles only Http protocol.

  Was this answer useful?  Yes

SUJATA WAGHMARE

  • Jan 10th, 2014
 

i think..genericserlvet handly any type of request..and httpservlet handly only http request this is different between genericservlet and httpservlet like..doget,dopost,dotrace()..theses are method of httpservlet class...both are classes

  Was this answer useful?  Yes

ReddySiddartha

  • Dec 12th, 2014
 

HttpServlet class extends GenericServlet Class which is an abstract class to provide the implementation to Protocol specific functionalities.GenericServlet should be used when we want to write the protocol specific implementation which is not avaible.But when you know we are making an internet application where http is major protocol its better to use HttpServlet class.

  Was this answer useful?  Yes

guru

  • Jan 27th, 2015
 

Http servlet extends Generic servlet both are abstract, generic servlet works all protocals where as httpservlet works with http and https protocol.generic servlet doesnt give implementatiion for service() where as httpservlet gives implementation for service method.

  Was this answer useful?  Yes

Abhishek yadav

  • Apr 22nd, 2015
 

Generic servlet can use only service method but in Http we use doGet ()& doPost ().
Http servlet are protocol dependent but generic servlet are protocol independent..
Best of luck!

  Was this answer useful?  Yes

Priyanka Garkal

  • Feb 25th, 2018
 

1.GenericServlet is base class of HttpServlet And HttpServlet is derived class of GenericServlet.

2.GenericServlet have abstract service() method whether HttpServlet has seven methods which can replace service() method ,They are Get(),Post(),Delete(),Put(),Head(),Trace(),Option().

3.GenericServlet does not support Session and Cookies where as HttpServlet supports session and cookies.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions