wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why no Exception for PUT,Delete,Trace.... 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 » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why no Exception for PUT,Delete,Trace...." Watch "Why no Exception for PUT,Delete,Trace...." New topic
Author

Why no Exception for PUT,Delete,Trace....

raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

I have a servlet which is having only doGet(...); in the form when i specify POST and submit it, it will throw me an exception saying POST() is not supported by this URL. When i specify any other Http methods like PUT,DELETE,OPTIONS,TRACE in the form method ,it will not throw any exception
instead it gives behaviour of doGET(). Why exceptions are not thrown for these methods like POST method.

I have checked the HttpServlet java code there is a default implementation for HEAD,OPTIONS and TRACE.for GET,POST,PUT,DELETE the implementation is same that is it will send an error message back to client using res.sendError(int,String); method.So at least for PUT and DELETE methods this should throw the exception.



Thanks

[ December 08, 2008: Message edited by: raja ram ]
[ December 08, 2008: Message edited by: raja ram ]
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

Any Updates on this.

Thanks
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

In a typical HTML file, you can specify GET and POST methods only! Other types (PUT,DELETE,TRACE,HEAD...) are for the purposes of testing and some other special implementations, as you can see here. That means, you cannot send a PUT, DELETE, TRACE,... request just by using a plain-old HTML file.

In other words,



is same as to,



Both of the above invocation sends a HTTP GET request to the web server, because GET is the default type for 'unknown' types, while "DELETE" and "djfjdshk" are unknown for HTML.

Devaka.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Yes,

Its true, only GET and POST are valid for HTML.rest all of them are meaning less and will be taken as default that is GET.I checked it by putting request.getMethod() it does print GET method for DELETE,OPTIONS,TRACE,....

Thanks for the info it cleared my doubt.

Thanks
[ December 11, 2008: Message edited by: raja ram ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why no Exception for PUT,Delete,Trace....
 
Similar Threads
How to call HEAD method ?
What are HTTP methods?
what is the reason for overriding the doGet() or doPost() method
Invoking HTTP Methods
how to delete .tmp file in server which is created during file upload