• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rookie Question about Servlet's Service method

 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not be angry. I am reading servlets for a first time. I have a hypothetical question. If I were to override service method in a servlet, how would I call the servlet implicitly?

If the method in the form defines whether doGet or doPost is invoked, then how does one call the service method?

Thanks,

Krishnan
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kartik
Please do not be angry. I am reading servlets for a first time.


Please feel free to ask any questions related to servlets in this forum, someone will guide you appropriately .

Originally posted by Kartik
If I were to override service method in a servlet, how would I call the servlet implicitly?


If you look at the GenericServlet, service method is abstract. So have to implemant this method in your class if you are extending GenericServlet.

The doXXX method are defined in HttpServlet class, this class has a well implemented service method which invokes one of these methods depending on the type of request, there is nothing stopping from overriding this service method but you dont gain anything by doing this.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container calls the service method for you, passing it the request.

By default, the service method will, depending on the type of the request, call either, doPost, doGet, doHead, etc..
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!