Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Must code doPost inside doGet

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()?
 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 3738
39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic