This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes doTrace in HttpServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "doTrace in HttpServlet" Watch "doTrace in HttpServlet" New topic
Author

doTrace in HttpServlet

sasikumar palakkizhi
Greenhorn

Joined: Sep 11, 2005
Posts: 29
Hi,

1. I used a file "form.html" and a java file "BeerSelect.java" for understanding the working of HTTP requests. When I overrided doTrace only in the HttpServlet in my class file, and requested for a resource using "PUT" method from an html file, i got a message that HTTP method Get is not supported by the URL.

2. Also I overrided doHead method only and used a form submission method of HEAD, I got the same message " HTTP method Get is not supported by the URL"

What are the reasons for this.

The code used for the second case is shown below( relevant parts)



The servlet is properly configured in web.xml and is working when i set both the methods as get.

Thanks in advance

Sasikumar
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The "method" property of the form tag does not just get passed verbatim to the server.

Html forms support 'get' and 'post'.
If it wasn't 'post' in your form, the browser most likely sent it as a 'get' request.

Running LiveHTTPHeaders while posting your form will show you exactly what method is being employed.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
sasikumar palakkizhi
Greenhorn

Joined: Sep 11, 2005
Posts: 29
Hi Ben,

Thanks for the help... using ieHTTPHeaders, i could understand that internet explorer generates only get and post requests irrevelent of the actual method i used in the form.

another point... does that mean ... we should have a client application rather than browser if we want to use put,head,trace and option methods?

thanks .. once again for the immediate help

sasikumar
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Your listed methods are also HTTP methods. But nobody use those usually. Client application would be the browser but the element would be something else not the <form>.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Yes, those methods aren't used by browsers.

WEBDAV clients use doPut.
I imagine the, lightweight, doHead could be useful if you had an applet or other client side code that needs to poll a server often (Head requests don't return the body).
sasikumar palakkizhi
Greenhorn

Joined: Sep 11, 2005
Posts: 29
Thanks for the immediate answers to adeel and ben...

regards
sasikumar
 
 
subject: doTrace in HttpServlet
 
Similar Threads
How to call HEAD method ?
Problem with accessing servlet from browser
Can't use trace, put, delete methods on tomcat
Accessing servlet
GET vs POST-Doubt