• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doGet(req,res) within doPost()

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I have seen a no. of codes for servlet where they have the doGet()implemented with some logic and in the doPost() has this within it doGet(req,res).Why is this required and what is its function within the code.Pls help
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. doGet() and doPost() get invoked by the service() method according to whether the HTTP request is a GET or a POST one. There are some cases where we want the servlet to handle GETs and POSTs in exactly the same manner.
An approach to this (which I like the most) is to write a method named (say) performTask() that does the actual work and have doGet and doPost call that one. Some people follow an alternative approach code either doGet or doPost and then have the one code the other.
... doGet(...) {
doPost(...);
}
This is essentially like telling the servlet container: "In the case of a GET request, do the same as in the case of a POST request".
Nothing more, nothing less.
Hope this helps,
Panagiotis.
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"performTask"? Do we still have VisualAge people out there?
 
Panagiotis Varlagas
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep. I'm an old VAJ guy...
But using WSAD since early 2002.
[ June 22, 2003: Message edited by: Panagiotis Varlagas ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic