• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP method HEAD arriving at servlet as GET .....

 
Finner Jones
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a servlet which overrides doHead() and doGet().
I have a JSP with a form action to call the servlet, the form method="HEAD" and a submit button.
However, the doGet() gets called instead of the doHead() in the servlet.
I have read that a HEAD is a GET but I was expecting the request to pass through doHead() first and then doGet().
When will the doHead() method be called in a servlet?


Thanks in advance
Finner

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML forms do not support anything but GET and POST. If you try to use something other than POST, it will be a GET.

You can send a HEAD request using JavaScript, though: Dynamic HTML and XML: The XMLHttpRequest Object
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another possibility is to tunnel the other methods through HTTP POST by using a URI query string like POST /myWebApp?method=PUT (and/or the X-HTTP-Method-Override header). Of course you will need to adjust your doPost() method ...

Programmatic clients can easily issue the remaining HTTP verbs. See java.net.HttpURLConnection.setRequestMethod(java.lang.String)
 
Finner Jones
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, Thank you!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic