• 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

HTML get and post method?

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

say we have html page and we are sending the values from html to server. First time we use the get method in html form.
I know that value will be passed as part of URL.But at serverside will we get it as part of HttpServletRequest and get the
passed value from HTML by request.getParameter("username");(in doget method)


If we do the above stuff with post method in HTML form .will we still get it as part of HttpServletRequestand get the
passed value from HTML by request.getParameter("username");(In dopost method)


Question2:- In case of get method values are passed as part of URL but how values get passed in case of post method?
(on some sites i have read it is passed posthttp but i did not get this meaning)


Question3:- One of my collegue asked me is there any we can only achieve with get method not with post. I am not aware of that.
Could any bodypoint me in that direction?
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,

difference between get and post will work for you? , i mean , i think ...you want to ask that "why we use "get"/ "doget"and when we use "post"/ "dopost" "? right ?

 
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

scott miles wrote:.will we still get it as part of HttpServletRequestand get the
passed value from HTML by request.getParameter("username");(In dopost method)


Yes.

Question2:- In case of get method values are passed as part of URL but how values get passed in case of post method?


Encoded in the request body.

Question3:- One of my collegue asked me is there any we can only achieve with get method not with post


As a rule of thumb, GET should be used when fetching information, and POST should be used when sending data to perform an operation. Things actually go a little deeper than that, but that's a good rule-of-thumb to get started.
 
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
And, GET and POST aren't part of HTML, they're part of HTTP.
 
scott miles
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear Bibeault for reply.

Encoded in the request body.



As per my understanding in case get method , attributes appended with URL will also be a part of request body though they wont be encoded. Does it mean that in case of post method , attributes will be passed in encoded form while in case of get method attributes wont be encoded and we can see the values in URL itself but both will be part of request body?

As a rule of thumb, GET should be used when fetching information, and POST should be used when sending data to perform an operation



Bibeault, As you mentioned GET should be used when fetching information, i think you are referring something like request.getParameter("username") kind of stuff here but as you said POST should be used when sending data to perform an operation, can you give a very small example what type of operation we are referring here ? Sorry for asking too much but did not get any concrete answer on different sites.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Small example.

"Give me the name of customer 123456" -- Get

"Set the name of customer 123456 to Freddy Gonzalez" -- Post
 
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
GETs have no body.

P.S. In Western cultures it is considered rude to address someone by just their last name. So it should be either Mr. Bibeault, or Bear.
 
Replace the word "snake" with "danger noodle" in all tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic