GeekInterview.com
Series: Subject: Topic:
Question: 177 of 177

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.
Asked by: Interview Candidate | Asked on: May 28th, 2005
Showing Answers 1 - 17 of 17 Answers
Srikanth Baki

Answered On : 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()

Yes  2 Users have rated as useful.
  
Login to rate this answer.
shyamalatha

Answered On : Sep 12th, 2005

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

  
Login to rate this answer.
gokulakrishnan

Answered On : 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.

  
Login to rate this answer.
hikarthik21

Answered On : Sep 20th, 2005

View all answers by hikarthik21

HttpServlet is a protocol dependent whereas GenericServlet is protocol independent

  
Login to rate this answer.
Chidambara Gupta. Cheedella

Answered On : 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.

  
Login to rate this answer.
Random

Answered On : 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

  
Login to rate this answer.
sudhakar

Answered On : Oct 15th, 2005

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

  
Login to rate this answer.
Saffy

Answered On : 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.

  
Login to rate this answer.
sma_raffy2000

Answered On : Oct 18th, 2005

View all answers by sma_raffy2000

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.

  
Login to rate this answer.
devendar

Answered On : 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.

  
Login to rate this answer.
rameshvdnv

Answered On : Apr 25th, 2007

View all answers by rameshvdnv

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.

  
Login to rate this answer.
Ravi Sindhal

Answered On : 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 onlyhttp specific protocols.

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

  
Login to rate this answer.
vinaymudgil007

Answered On : Aug 30th, 2009

View all answers by vinaymudgil007

HttpServlet is a specific case/implementation of GenericServlet.


Thanks,
Vinay

  
Login to rate this answer.
JOE

Answered On : Sep 21st, 2011

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

  
Login to rate this answer.
gayathri

Answered On : 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

  
Login to rate this answer.

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.

  
Login to rate this answer.
SUJATA WAGHMARE

Answered On : 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

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.