'difference'에 해당되는 글 1건

  1. 2010.03.16 Methods GET and POST in HTML forms - what's the difference?
참조 : http://www.cs.tut.fi/~jkorpela/forms/methods.html

아래 소스로 파일 작성 후 Get, Post에 해당하는 각각의 function을 실행시켜보면
각 방식 별로 form 처리가 어떻게 되는지 확인할 수 있다.

formTest.htm
<html>
  <head>
    <title>Processing Form Test</title>
    <script language="javascript">
    <!--
      function fnSubmitGET() {
        var form = document.testForm;
        form.action = "127.0.0.1/test.do";
        form.method = "GET";
        form.submit();
      }
     
      function fnSubmitPOST() {
        var form = document.testForm;
        form.action = "127.0.0.1/test.do";
        form.method = "POST";
        form.submit();
      }
    -->
    </script>
  <head>
 
  <body>
    <form name="testForm">
      <input type="text" name="key1" /><br>
      <input type="text" name="key2" />
      <input type="button" name="btn1" value="Get" onclick="javascript:fnSubmitGET();" />
      <input type="button" name="btn2" value="Post" onclick="javascript:fnSubmitPOST();" />
    </form>
  </body>
</html>

-----------------------
http://127.0.0.1:8080/WebTest/WebContent/formTest.htm

result:
fnSubmitGET() -->
            http://127.0.0.1:8080/WebTest/WebContent/127.0.0.1/test.do?key1=123&key2=123
Get 방식의 경우 URL 뒤에 추가하기 때문에(마치 링크처럼) 위와 같은 모양이 된다.
나중에 해당 URL을 복사해서 즐겨찾기로 활용할 수 있다.

- Standard input stream data(Stn)
GET /WebTest/WebContent/127.0.0.1/test.do?key1=123&key2=123 HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, */*
Referer: http://127.0.0.1:8080/WebTest/WebContent/formTest.htm
Accept-Language: ko
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30)
Host: 127.0.0.1:8080
Connection: Keep-Alive

fnSubmitPOST() -->
http://127.0.0.1:8080/WebTest/WebContent/127.0.0.1/test.do
Post 방식의 경우 request의 message body에 추가하기 때문에 URL 상의 변화는 없다.

- Standard input stream data(Stn)
POST /WebTest/WebContent/127.0.0.1/test.do HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, */*
Referer: http://127.0.0.1:8080/WebTest/WebContent/formTest.htm
Accept-Language: ko
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30)
Host: 127.0.0.1:8080
Content-Length: 17
Connection: Keep-Alive
Cache-Control: no-cache

key1=123&key2=123

Posted by 라딘.

댓글을 달아 주세요