Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when we use Get method & when we use get post method in the Servlet?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
fist Declare post method
inside the post method you declare
doGet(request, response);
thats all
....
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic