• Post Reply Bookmark Topic Watch Topic
  • New Topic

doGet() and doPost()  RSS feed

 
jose chiramal
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 ?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • 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, ...
 
prakash pawar
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

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!