473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GET vs POST

I'm still quite unclear as to what exactly the difference between METHOD=GET
and METHOD=POST is for forms, even after looking in several books an on the
web. I'd appreciate any clarifications you could give me.

I'm in a situation where I'd like to pass the elements of a Javascript date
separately (year, month, date, hour, minute, second) to a CGI. If I were to
store these values in a hidden form and at some point submit that form, would
I want the method for that form to be GET or POST?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 20 '05 #1
10 21075

"Christopher Benson-Manica" schreef...
I'm still quite unclear as to what exactly the difference between METHOD=GET and METHOD=POST is for forms, even after looking in several books an on the web. I'd appreciate any clarifications you could give me.

I'm in a situation where I'd like to pass the elements of a Javascript date separately (year, month, date, hour, minute, second) to a CGI. If I were to store these values in a hidden form and at some point submit that form, would I want the method for that form to be GET or POST?


Hi,

This may be a good starting point:

http://www.w3.org/TR/html4/interact/...#submit-format

Some practical things:

A GET can be bookmarked, while a POST can usually not.
Form data from a GET is easely recovered from history, thus not usable for
things like passwords.

Fred
Jul 20 '05 #2
Christopher Benson-Manica wrote:
I'm still quite unclear as to what exactly the difference between
METHOD=GET and METHOD=POST is for forms, even after looking in several
books an on the web. I'd appreciate any clarifications you could give me.
Get encodes the data in the query string section of the URI and is for
queries which don't make any change on the server. As the data is in the
URI, it is bookmarkable.

Post encodes the data as seperate http headers, and is for queries which do
make changes on the server. Post also allows much more data to be sent.
I'm in a situation where I'd like to pass the elements of a Javascript
date separately (year, month, date, hour, minute, second) to a CGI. If I
were to store these values in a hidden form and at some point submit that
form, would I want the method for that form to be GET or POST?


That depends what you want to do with it.

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #3
The main difference that matters most, to us as developers, is the placing
of all the "stuff" sent along when you "submit" a form.

Suppose you have a <input type="input" name="junk"> on your form.
When the form is submitted, the URL specified on the <form ACTION="URL"> is
called.
This URL will receive a parameter name/value pair of "junk=(contents of the
input box)"

If the <form> specified a METHOD of GET, <form ACTION="URL" METHOD="GET">,
the URL will be called
as the following
"URL?junk=(contents of the input box)"

If the <form> specified a METHOD of POST, <form ACTION="URL" METHOD="POST">,
the URL will be called
as the following
"URL"
Note, there is no "?junk=(contents of input box)" text string trailing the
URL.

The receiving URL will still have access to the "junk=(contents of input
box)" name/value pair, but it does not show up in the browsers URL location
box.

The name/value pair of "junk=(contents of input box)" is in the HTTP headers
(I think). In either case the following ASP code will retreive the
name/value pair...
Request("junk")

The statement Request("junk") will return the string that is the contents of
the text box when the form was submit'ted

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bo**********@chessie.cirr.com...
I'm still quite unclear as to what exactly the difference between METHOD=GET and METHOD=POST is for forms, even after looking in several books an on the web. I'd appreciate any clarifications you could give me.

I'm in a situation where I'd like to pass the elements of a Javascript date separately (year, month, date, hour, minute, second) to a CGI. If I were to store these values in a hidden form and at some point submit that form, would I want the method for that form to be GET or POST?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.

Jul 20 '05 #4
In article <bo**********@chessie.cirr.com>, at***@nospam.cyberspace.org
enlightened us with...
I'm still quite unclear as to what exactly the difference between METHOD=GET
and METHOD=POST is for forms, even after looking in several books an on the
web. I'd appreciate any clarifications you could give me.

http://ist-socrates.berkeley.edu:730...ec/page17.html
I'm in a situation where I'd like to pass the elements of a Javascript date
separately (year, month, date, hour, minute, second) to a CGI. If I were to
store these values in a hidden form and at some point submit that form, would
I want the method for that form to be GET or POST?


Depends on your needs. See link above.

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #5
Christopher Benson-Manica wrote:
I'm still quite unclear as to what exactly the difference between
METHOD=GET and METHOD=POST is for forms, even after looking in several
books an on the web. I'd appreciate any clarifications you could give me.
GET retrieves a resource from a server. POST sends information to a server,
and (usually) gets a resource in response.

I'm in a situation where I'd like to pass the elements of a Javascript
date separately (year, month, date, hour, minute, second) to a CGI. If I
were to store these values in a hidden form and at some point submit that
form, would I want the method for that form to be GET or POST?


It depends why you are doing it. If the form handler is supposed to take
that information and store it in a database or something, then use POST.
If you are retrieving time-sensitive information, use GET. If the amount
of information is 'large', then use POST as well, since you can't rely on
extremely long URLs to be handled correctly.

The HTTP 1.1 specification, RFC 2616 goes into more detail:

<URL:http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9>
--
Jim Dabell

Jul 20 '05 #6

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bo**********@chessie.cirr.com...
I'm still quite unclear as to what exactly the difference between METHOD=GET and METHOD=POST is for forms, even after looking in several books an on the web. I'd appreciate any clarifications you could give me.

I'm in a situation where I'd like to pass the elements of a Javascript date separately (year, month, date, hour, minute, second) to a CGI. If I were to store these values in a hidden form and at some point submit that form, would I want the method for that form to be GET or POST?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.


Besides whatevery one else has mentioned - I believe GET is confined to 1024
characters while POST has no such limits.. though limits on client memory,
connection speed and client/server timeouts might effect a really long
POST...
Jul 20 '05 #7
r a n d e l l d, on Thu, 06 Nov 2003 05:20:15 +0000, had to say:
Besides whatevery one else has mentioned - I believe GET is confined to
1024 characters while POST has no such limits.. though limits on client
memory, connection speed and client/server timeouts might effect a
really long POST...


GET is confined to 256 characters.

From w3.org:
(http://www.w3.org/2001/tag/doc/whenT...-20030509.html)

5.2 Ephemeral limitations

While Web application design must take into account the limitations of
technology that is widely deployed at present, it should not treat these
as architectural invariants. The following is a list of limitations have
already been largely resolved, or are likely to fade away as bugs are
fixed and the scope of interoperable specifications expands.

URIs cannot be longer than 256 characters
This was a limitation in some server implementations, and while
servers continue to have limitations to prevent denial-of-service
attacks, they are generally at least 4000 characters, and they evolve
as the legitimate uses of application developers evolve.
GET requests are re-executed when the user uses the back button.
This is not by design. Section 13.13 of [RFC2396] states: "History
mechanisms and caches are different. In particular history mechanisms
SHOULD NOT try to show a semantically transparent view of the current
state of a resource. Rather, a history mechanism is meant to show
exactly what the user saw at the time when the resource was
retrieved."
If I visit a page via a secure protocol, and then follow a link to another
page, the second site may have access to sensitive data in a URI.
This is not by design. Section 15.1.3 of [RFC2396] states: "Because
the source of a link might be private information or might reveal an
otherwise private information source, it is strongly recommended that
the user be able to select whether or not the "Referer" [sic] field is
sent. For example, a browser client could have a toggle switch for
browsing openly/anonymously, which would respectively enable/disable
the sending of Referer and From information. Clients SHOULD NOT
include a Referer header field in a (non-secure) HTTP request if the
referring page was transferred with a secure protocol."
Search services will not index anything with a "?" in the URI.
This was a heuristic to avoid infinite loops in some search service
crawlers, but it was not an architectural constraint, and modern
search services use more sophisticated heuristics to avoid loops.

Jul 20 '05 #8
Get -- limits amount of data u can send over wire from one page to
another.

Not secured.... as data goes as query string...

Post --- no limit on amount of data to be sent over wire...

secured way of sending data... in form of form elements...

Keyur Shah
Verizon Communications
732-423-0745

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #9
Mikhail Esteves wrote:
r a n d e l l d, on Thu, 06 Nov 2003 05:20:15 +0000, had to say:

Besides whatevery one else has mentioned - I believe GET is confined to
1024 characters while POST has no such limits.. though limits on client
memory, connection speed and client/server timeouts might effect a
really long POST...

GET is confined to 256 characters.


No, you're not correctly reading the material you quoted. As pointed out
in previous posts, the GET data is transmitted in the request URI. The
RFCs do not specify a limit; this is implementation-specific.

What the quoted paragraph below states is: Some older server
implementations may have placed a 256-char limit, but generall NO LONGER
DO. (Shoot, a HOSTNAME can be up to 255 chars, so it doesn't make much
sense to limit an entire URI to 256.)

Some servers do implement limits on both URI size and request-body size
in order to thwart DOS attacks employing huge URIs or request-bodies.
URI limitations at the client side are likely to be OS or browser
properties. For example in Windows, the limit is 2083 characters (e.g.
as defined in commctrl.h or wininet.h -- see the MS platform SDK).

The maximum amount of GET data that can be transmitted in the URI will
be the OS/browser limitation on total URI size minus the total of the
length of the scheme + 3( the "://" ) + hostname + urlpath + 1 for the
"?" delimiting the query string. If there's any room left over, that's
how much room you have for your GET data. This is independent of what
any particular server may accept.
From w3.org:
(http://www.w3.org/2001/tag/doc/whenT...-20030509.html)

5.2 Ephemeral limitations

[...snip...] The following is *a list of limitations have [sic]
already been largely resolved* [emphasis added], or are likely to fade away as bugs are
fixed and the scope of interoperable specifications expands.

URIs cannot be longer than 256 characters
This *was* a limitation in some *server implementations* [emphasis added], and while
servers continue to have limitations to prevent denial-of-service
attacks, they are generally at least 4000 characters, and they evolve
as the legitimate uses of application developers evolve.
[...snip...}


Regards,
Stephen

Jul 20 '05 #10
Mike wrote:
The main difference that matters most, to us as developers, is the placing
of all the "stuff" sent along when you "submit" a form.

Suppose you have a <input type="input" name="junk"> on your form.
When the form is submitted, the URL specified on the <form ACTION="URL"> is
called.
Picky, perhaps, but more correct to say that the resource identified by
the URL is "requested", whether GET or POST (or any other method) is used.
[...snip...]
[For POST,]
The name/value pair of "junk=(contents of input box)" is in the HTTP headers
(I think).


Using request method POST, the name=value pairs are contained in the
body of the request.

Request line: POST /some/file.asp HTTP/1.1
Headers: Host: http://example.com
<may be more headers>
Blank line: <extra CRLF pair separates headers from body>
Body of request: <name=value pairs go here>
Regards,
Stephen

Jul 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an ASP file and sends the name either by GET or POST....
1
by: khawar | last post by:
my application is in asp.net using C# hi guys having a complicated problem i am using payflowlink to process CC payments I have to send a httppost to their servers. The problem is how do i do a...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
1
by: Manuel | last post by:
I have to log into a website and retrieve some information. The problem is that the post isn't "normal". I'm used to passing post values in the form of: Variable1=Value1&Variable2=Value2 etc. I...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
9
by: c676228 | last post by:
Hi, I am new to this discussion forum. I started to post questions on this forum since this Jan. and got many good responses and I am very appreciated to those who are willing to help with their...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
10
by: Peter Michaux | last post by:
Hi, All Ajax libraries I've read use encodeURIComponent() on the name- value pairs extracted from forms before POST ing the result to the server with and xmlhttprequest. I can understand why...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.