Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

how call the doGet method

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i have one question : i want to know who call the doGet method or doPost method container or service method.

answer is
[code]
Answer


C)

This code is valid and will handle all three types of HTTP requests including GET, POST, and PUT.

D)

The next method invoked is destroy.

[/code}
i don't have problem with second answer [d] but i have problem with choice [c] please clear it.
thanks in advance
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Markandey.

The service method is the one responsible to call doGet, doPost, doPut, depending on the request type. In this case, it is just not calling these methods (but it's handling the requests anyway). Is it clear?
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand this right.

You could overwrite the service-method if you want a single method which handles the doGet, doPost, doPut.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It rarely makes sense to override the service method: Servlet FAQ entry
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no Hard and fast rule to override service method if you extend HttpServlet.Since service method implementation is provided in HttpServlet class.Container will call this service method if you don't override it.
Here there is logic which will call your doXxx() methods depending on its method type.If your overriding service method you are telling the container please call my service method rather than service method of HttpServlet class
please correct me if i m wrong
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There is no Hard and fast rule to override service method


True, but there are good reasons not to do so; the FAQ entry lists two of them.
 
Everybody's invited. Except this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic