views:

513

answers:

3

I've a servlet running on Tomcat 5.5.27 and 5.5.26 and have a web form with POST method. If I use Safari 3.2.1 I see from the logs that Tomcat receives a POST followed immediately/contemporarily by GET and it fails. If I use Firefox 3.0.5 I see that it sends only POST and everything works.

Trying to debug with Eclipse I see that when using Safari it is the doGet() method that is called while when using Firefox is doPost().

Practically it seems that Safari fires both POST and then immediately GET, while Firefox fires only POST (as it should according to the HTML form).

Is there somebody else who as experienced this ? In this case is there a solution ?

Here is a snippet of the HTML form:

<form action="/vidisearch/Search" method="post" name="SearchForm" id="SearchForm">
    <div class="input required">
    <label for="Concepts">Concepts, comma separated<br />
    ex. (remove quotes) &quot;man-made object, cemetery, graphic event, atmospheric event, tool event&quot;</label>
    <input name="concepts" type="text" value="" id="concepts" />
    </div>

    <div class="input required">
    <label for="Operators">Operators, comma separated<br />
    ex. (remove quotes) &quot;NOT, AND, OR, AND, AND&quot;</label>
    <input type="text" name="operators" value="" id="operators" />
    </div>

    <div class="input required">
    <label for="Specializations">Specializations, comma separated<br />
    ex. (remove quotes) &quot;true, false, false, true, false&quot;</label>
    <input type="text" name="specializations" value="" id="specializations" />
    </div>

    <div class="input required">
    <label for="Results">Various parameters</label>
    <table width="100%" border="0" style="border: 0;">
    <tr>
    <td>Ontology ID<br />
    <input name="ontologyID" type="text" id="ontologyID" value="" /></td>
    <td>Result page<br />
    <input name="page" type="text" id="page" value="0" /></td>
    <td>Shots per page<br />
    <input name="shotsPerPage" type="text" id="shotsPerPage" value="20" /></td>
    <td>New search<br />
    <input name="newSearch" type="text" id="newSearch" value="true" /></td></tr>
    </table>
    </div>

    <div class="submit"><input type="submit" value="Search" /></div>
</form>
A: 

It's hard to say without seeing your HTML for the form, but perhaps your submit button is a wrapped with a link, and Safari is both POSTing the form and following the link (via GET).

Marc Novakowski
I've added the snippet of HTML code of the form. As you can see there's no <A> link wrapping the submit button.
Marco
A: 

I'm not sure what's happening but what I do know is that you need to provide more information.

Maybe it's sending a GET for associated resources (like images) whereas Firefox keeps them in the cache, or you have the form submit button inside an <a> tag, for instance.

Another alternative is a Javascript incompatibility, in case you are submitting something via Javascript.

Sniff the traffic (check out Fiddler or Wireshark) and see what is Safari trying to GET and what's it is POSTing

Vinko Vrsalovic
I'll try Wireshark. Anyway the GET was logged by Tomcat, so I think that it's GETting the servlet. I'm going to check anyway.
Marco
I'm not using any Javascript and the button is not inside a <A> link.
Marco
A: 

I'm quite puzzled by the behaviour of Safari since I remind that sometime ago it worked. I'm fearing that one of the latest upgrades has broken something.

Using HTTPScoop I've seen that apparently Safari fires POST followed by GET when it gets the response. I think however that it actually fires both requests at the same time since the date+time of the two responses is the same for both POST and GET.

The response is a RSS feed and has the HTTP/1.1 200 OK code. The second GET asks for the same request URL (http://127.0.0.1:8180/vidisearch/Search) of the POST but the body is 0 bytes, it has of course no GET parameters and the answer is wrong because of the missing parameters.

Firefox instead fires only the POST and gets the correct answer.

Marco