Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Any Updates on this.

Thanks
 
Sheriff
Posts: 6888
1312
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic