Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
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
 
Sheriff
Posts: 6611
1253
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • 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 ]
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic