• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GenericServlet

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpServlet extends GenericServlet, so we can access all methods of GenericServlet from HttpServlet itself.So, by extending HttpServlet, can we write a GenericServlet?

------------------
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Thilak
there is a difference in the way the Servlet Engine handles the Generic servlet and the Http Servlet.
The Generic Servlet needs the service method to be overidden while the httpServlet needs the doGet or the doPost method to be overidden .The Calls to these are however routed through the Service method .
I cant understand why you need to do the thing you mentioned as you can see there is not much gained by trying to replicate the generic functionality in the httpServlet.
Thats why the HttpServlet was made
regards
pranav

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You will have to subclass the GenericServlet class and provide implementation for the service() method. You might want to refer to the Sun Tutorial on Servlets and the Java servlet programming book for reference.
Ashwin.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can write a generic servlet by extending HttpServlet, though it doesn't make much sense.
The HttpServlet overrides the service() method of GenericServlet and reroutes the request to doGet() or doPost() method depending on the request type. So you can subclass the HttpServlet and override the service method to provide our own behaviour.
 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic