• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Servlet

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Friends,
A basic question on servlet.We have GenericServlet class and is declared as a Abstract class,
We have one more class httpServlet is again an Abstract class which extends our Generic Servlet class.So it is learnt that what all classes extends httpServlet class, must implement atleast any one of the methods listed below.
doGet
doPost
doPut
doDelete
init
getServletInfo
My doubts are
1)Why GenericServlet is declaed as abstact as it has no single method as abstract?
2)How does the rule applied on httpServlet class as what all classes extends this class must
implement atleast one of the above methods?
thanks in advance for helping me to know the hidden strategy
prashanth
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1)Why GenericServlet is declaed as abstact as it has no single method as abstract?
Becuase it's not meant to be used directly. The intent is for it to be extended.


2)How does the rule applied on httpServlet class as what all classes extends this class must
implement atleast one of the above methods?

You don't have to implement any of those methods. They're all implemented for you. You could certainly write and compile a servlet with none of those methods in it. It just wouldn't do anything.

You'll want to override one of those methods if you intend to have it do some work for you.

Think of the HttpServlet as a template with all the heavy lifting already done for you.

thanks in advance for helping me to know the hidden strategy

There's nothing hidden about it. It's all publicly documented in both the
API and in the Servlet Spec.
[ February 16, 2005: Message edited by: Ben Souther ]
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic