Forums Register Login

HTML get and post method?

+Pie Number of slices to send: Send

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?
+Pie Number of slices to send: Send
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 ?

+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
And, GET and POST aren't part of HTML, they're part of HTTP.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Small example.

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

"Set the name of customer 123456 to Freddy Gonzalez" -- Post
+Pie Number of slices to send: Send
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.
Don't touch me. And dont' touch this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1310 times.
Similar Threads
Not able to set attribute in JSP
Help me writing an ACTION class in eclipse
Unable to compile class for JSP
Passed
Checkbox value not being passed to bean.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:52:35.