This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes Why dont we use GenericServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why dont we use GenericServlet " Watch "Why dont we use GenericServlet " New topic
Author

Why dont we use GenericServlet

abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
GenericServlet is an abstract class it can handle all types of protocols,but HttpServlet handle only Http specific protocols

then Why dont we use GenericServlet
Ashwin Sridhar
Ranch Hand

Joined: Jul 09, 2011
Posts: 272

GenericServlet is a Abstract class. You need to implement all the unimplemented methods.

For Http protocols, these methods are implemented by the HttpServlet class and we simply extend it and use it in our servlet.

but nothing stops us from using GenericServlet abstract class. Infact we need to use GenericServletif we are going to use any protocol other than HTTP.


Ashwin Sridhar
SCJP | SCWCD | OCA
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42371
    
  64
Also see http://www.coderanch.com/how-to/java/ServletsFaq#overriding-service and http://www.coderanch.com/how-to/java/ServletsFaq#otherProtocols


Ping & DNS - my free Android networking tools app
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
Thanks Ashwin Sridhar, Ulf Dittmer


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why dont we use GenericServlet