In Core Servlets and JSPs, when a POST method is used, many of their examples have doPost() call doGet(). I'm just curious what is seen in the real world? I'm used to just using doPost(), even if there is no overriding doGet method. Is one way preferred over the other for some reason? Thanks! Jason
If your page can, and is accessed through doGet (i.e clicking on a link, typing the address in the URL), and you don't have a doGet method, you will get an error. If theere is a chance that your page can be accessed by both methods, it's good to handle both.
Bosun (SCJP, SCWCD).
So much trouble in the world -- Bob Marley
Most of the time, the navigation through a web application is done using links. So the doGet() method has to be implemented. And when you have forms, the POST method is often the one specified. So the doPost() has to be implemented. That's why the way it is done within Core servlets is a good one. Both methods are handled, but the script is only written once. Another way is the IBM VAJ one. it creates a performTask(request, response) methog, and doGet() doPost() call this method.
/ JeanLouis<br /><i>"software development has been, is, and will remain fundamentally hard" (Grady Booch)</i><br /> <br />Take a look at <a href="http://www.epfwiki.net/wikis/openup/" target="_blank" rel="nofollow">Agile OpenUP</a> in the Eclipse community
Chicken Farmer ()
posted 18 years ago
I've implemented a similar solution going through the Cattle Drive Servlets and JDBC, and it works great (especially with subclasses). Mainly I was curious if you've written an HTML form the uses POST, would you really want to have doPost call doGet. But I guess after reading y'alls replies, it is just safer to get in the habit of implementing both just in case. Thanks! Jason