• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Must code doPost inside doGet

 
riohk kurn
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it true that no matter the method of form is Get or Post, doGet will be invoked, and we need to include doPost inside doGet.
However, it makes me confused, as service() of GenericServlet will choose doXXX depending on situation. So, why we need to include doPost inside doGet()?
 
Bhushan Jawle
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it is not true that doGet is always called irrespective of form method specified. If nothin is specified, it is called by default but if you specify mehtod="POST" doPost is called instead
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, riohk
this is a matter of application design
some developers want their servlets process any HTTP request, in this case to avoid code duplication, they write code for data processing, put it either in doPut or doGet method and put stub in another method, i.e.
...... doGet(...) {
doPost(....);
// and nothing more
}
..... doPost(....) {

// code for request processing
}
cheers!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic