Hi, Now, I do understand the difference b/w form's GET and POST methods, but when it comes to servlets, I've seen doPost() just calls the doGet() (the book is Marty Hall's Core Servlets and JSP). If that is the case, why have 2 diff. methods ? I mean shouldn't they have different purposes?
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
The two methods are there because they represent two different HTTP requests (there are also doHead(), doOptions() etc, but they are rarely used). If your application needs to give the same response to both POST and GET requests, then setting one to call th eother is a reasonable way to do it.
Originally posted by Vishakha Ahuja: Hi, Now, I do understand the difference b/w form's GET and POST methods, but when it comes to servlets, I've seen doPost() just calls the doGet() (the book is Marty Hall's Core Servlets and JSP). If that is the case, why have 2 diff. methods ? I mean shouldn't they have different purposes?
The book you mentioned"Core servlets and JSP" by Marty Hall has clearly described the 2 methods and their relevance. Please go through the JSP section once again to get a clear understanding.
Brett Knapik
Ranch Hand
Joined: Oct 15, 2000
Posts: 255
posted
0
Get and post methods can be used for security. Lets say that you have a shopping cart application if you use the get response when the user enters their credit card it will be in the browser bar leading to hackers for CC information. If you use a post you are safe just as long as you are in SSL. ------------------ In Gates we trust. Yeah right....
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4089
posted
0
I prefer using Post when I can because of what Brett said. Also if you use doGet() the person can bookmark the page, with doPost() they cant. doGet is the only way to call a servlet from a <a href so it is very useful in that way.
[This message has been edited by Randall Twede (edited March 07, 2001).]