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
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.