File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when to use get method versus post method in the servlet?

 
BalaMurali dhar
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we use Get method & when we use get post method in the Servlet?
 
Paul Clapham
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To put it briefly, you use the POST method when your request is meant to change the state of the server. That would include updating databases, adding to shopping carts, and things like that. You use the GET method when your request is not meant to change the server's state; that would include requests for information from the server.

There are grey areas and complexities which I haven't mentioned, as there always are in questions of this type, but that's the general idea.

For example if my request is supposed to make a dentist appointment for me next Tuesday at 11 AM, that would be a POST request because that information is going to be stored at the server. However if my request is supposed to find out what times are available for appointments on Thursday, that would be a GET request.

 
caushik conjetty sekhar
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We use POST method when we want to submit the data to the server, For example if you are submitting the details of an employee. Use GET method when you want to bookmark your page or retrieve simple data. GET is not secure since the data is appended in the URL, in POST data is sent in the body so the data is not seen to outside world.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
caushik conjetty sekhar wrote:Use GET method when you want to bookmark your page or retrieve simple data.

Complexity of the data is irrelevant. The GET method should be used to get data regardless of whether it is complex or simple.

GET is not secure since the data is appended in the URL, in POST data is sent in the body so the data is not seen to outside world.

This is a popular myth, and is completely wrong.

Just because POST data is in the body of the request it is no more secure than data placed on the URL. All unencrypted data sent over the Internet is visible to anybody along the way.

POST is in no way more secure than GET, and GET is no less secure than POST. If you want to protect the data, use SSL to encrypt the transmitted data.
 
RajeshKumar Nayak
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fist Declare post method
inside the post method you declare
doGet(request, response);
thats all
....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RajeshKumar Nayak wrote:fist Declare post method
inside the post method you declare
doGet(request, response);
thats all

No, that's not all. You cannot declare one method inside another. What on Earth are you talking about?

Even so, another myth is that EGT and POST are interchangeable. They are not as described above. Each is used for different purposes.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic