my dog learned polymorphism*
The moose likes Servlets and the fly likes exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "exception" Watch "exception" New topic
Author

exception

rakhi sinha
Ranch Hand

Joined: Mar 26, 2012
Posts: 147
how to remove this exception


HTTP Status 405 - HTTP method POST is not supported by this URL

--------------------------------------------------------------------------------

type Status report

message HTTP method POST is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).


--------------------------------------------------------------------------------

Apache Tomcat/6.0.32

i have removed it.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 538

You do not have doPost() method overridden in your servlet, but you access the servlet with POST method, that's the reason why this exception is coming. To overcome this exception, override doPost() method or do not call this servlet with POST method..
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

Inside your servlet, if you have goGet() method & if you want to support GET & POST both, then add following code inside your class -

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You should not use GET and POST interchangeably, the HTTP specification is very clear about that. The "solution" mentioned by Anurag Verma is thus not viable.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 538

Anurag Verma wrote:Inside your servlet, if you have goGet() method & if you want to support GET & POST both, then add following code inside your class -


Having both doGet() and doPost() do the same thing is not a good practice. They both are there for different purposes.
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

Hi Prasad,
This is already mentioned -
if you want to support GET & POST both, then add following code


i know this is not good way, but if someone needs it, then this is the way
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
There's no way this is ever "needed" - it can easily be avoided by various means. And as pointed out already, it violates the HTTP spec, with all the adverse consequences that can have. So you should never advocate it.
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

sorry
 
Consider Paul's rocket mass heater.
 
subject: exception