Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

doGet() and doPost()

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. doget() and doPost() methods are mandatory ? What would happen if i do not override these methods ?

2.Why do we override the doGet and/or doPost methods instead of the service method? (I read this in faq section, but not satisfied)


3.Can we explicitly call doGet() doPost() methods ? I know tht the service method calls them.


4. Can i call service method ?
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1. doget() and doPost() methods are mandatory ? What would happen if i do not override these methods ?


What happened when you tried this?

2.Why do we override the doGet and/or doPost methods instead of the service method? (I read this in faq section, but not satisfied)


What did and did you not understand about what's written in that page? Knowing that will make it easier for people here to address the question.

3.Can we explicitly call doGet() doPost() methods ?


Again, what happened when you tried this?

4. Can i call service method ?


Again, ...
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The basic purpose of servlet is to serve the Request and generate the Response.

As there is any Request from client Web Container call the service(HttpServletRequest req, HttpServletResponse resp) method of corresponding
servlet.

here in the service it indentify the type of action Method it may be any of the following type

GET,POST,HEAD,PUT,DELETE,OPTION,TRACE and call the corresponding method of servlet.

generaly we deal with GET OR POST only.

so what ever business logic we have to get out from Servlet. we do it either in doPost () or doGet().
coming to your queries :-

1) No it is not mandatory to override the doPost or doGet method and if you want any business logic to be perform do it in service method only.

2) we override doPost or doGet specifical. If when we want to serve the client Request based on the type of action Method .

3) No we cant explicitly call doGet() doPost() methods as they get called from service itself.

4) No we cant call the service method, as it is called by the Web Container.

Regards,
Prakash Pawar

 
I was born with webbed fish toes. This tiny ad is my only friend:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic