• 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

Request Parameters for GET and POST

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

I am trying to test the Servlet basics on the tomcat server. For the GET method, the request parameters are passed in the address line. I developed a small servlet which read all the parameters and display it. Working fine. I place these servlet as the action element in the HTML FORM and test for default GET and another POST method. Aslo working fine. BUT....

When I tried the following URL in HTML FORM action attribute using GET method

/myapp/TestServlet?name=narendra

while running, in the browsers address bar, the ?name=narendra is ignored and the FORM fields are appended. OK

Surprisingly, when I tried the same using POST method, The name parameter from the addtess bar is included in the parameter list along with the form parameters. I understand that the request paremeters for POST method are palced the the message body.

How?

Thanks
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question are confuse, but I ll explain what I know about HTTP GET and HTTP POST, I hope that help you:
HTTP GET: the query String is putted on the request of the HTTP protocol, like this:

GET /myapp/servlet/MyServlet?name=Joao&address=Rua das Couves
<headers>
<msg-body or payload>
It limits the query string length and is insecure way.

POST /myapp/servlet/MyServlet
<headers>
<query string and msg-body or payload>
Its more secure and the query string is putted here automatically. The server side know that.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But Does GET request have a pay-load/body? Its stated in HFS (Page:125) that GET request doesn't have a body..

Pls clarify..
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying something like this.

<form action='/myapp/TestServlet?name=narendra' method=post>
<input name='name' type='text'>
.......................
<input type='submit>
</form>

while executing this HTML, the servlet shows the name valus as narendra and karteya (the input given through Form.

But when I change the method=get, it is showing me name values as karteya only.

I am confused why the post method display the values in query string in the above example and get method ignored it.

thanks
[ May 12, 2005: Message edited by: Narendra Dhande ]
reply
    Bookmark Topic Watch Topic
  • New Topic