wood burning stoves 2.0
The moose likes Servlets and the fly likes get v/s post request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "get v/s post request" Watch "get v/s post request" New topic

get v/s post request

Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
My application is making a post request and action URL is assigned to form in the javascript dynamically.
But his URL also contains query string also e.g.

document.myform.action = 'http://www.abc.com/myapp/servlet/MyServlet?event=continue'

In some of the request processed at the serlvet level only value event=continue is received. Other parameters of the form are not received. It appears that form contents are not posted or evenif posted only values from query string are taken i.e. it may be treated like a GET request rather than POST request.

But this happens only in around 20% cases.

Any help of this would be highly appreciated.

Sanjeev Kaushik
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 671
exam your query string. It may contain special char.

Also you can change form ACTION to GET so that you will see exactly what is sent to server.

We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17276

GET and POST are mutually exclusive and which one is actually used is determined by the browser.

Specifically, if you code a hyperlink or enter the URL manually, a GET request will be made. If you code a form with a 'method="POST"', a POST will be made. A form with no method given defaults to GET, but in Struts, the Struts form defaults to POST.

The format of the URL is immaterial, since the GET or POST request is made as an HTTP command by the browser. A server that attempts to decode a POST request's URL to pull "GET" parameters out is working improperly.

An IDE is no substitute for an Intelligent Developer.
wood burning stoves
subject: get v/s post request
It's not a secret anymore!