• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Any Updates on this.

Thanks
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4598
303
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic