• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference bet doGet and doPost

 
Bharatesh H Kakamari
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between doGet and doPost methods in the Servlets API. doGet() services the GET requests and doPost() services the POST requests (specifed through method=***). But again what is difference between GET requests and POST requests. To me both seem the same. Please help!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The GET and POST methods are different in the following ways:
There is a limitation on the number of characters that can be passed to the JSP/ASP using GET method(I am not sure about the exact number).Using the POST method,there is no such limitation.Therefore,only if you are passing a very limited number of characters from your HTML page in the FORM post,one should use GET.
The reason is the data passed using GET is in continuous form whereas,the data passed using POST is broken into packets and sent.
Also,GET is not suitable for passing confidential data,as the data passed by a GET request appears along with the URL at the top of your browser window after a question mark,on submitting the form in HTML.Using POST,this does not happen.

 
Randall Twede
Ranch Hand
Posts: 4481
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lakshmi,
good answer! I just want to add that when you call a servlet(orJSP) from a link it is always a Get not a Post. You can only Post from a form.
------------------
Dont blindly believe everything I say.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic