*
The moose likes Servlets and the fly likes HTTP Status 405 - HTTP method GET is not supported by this URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP Status 405 - HTTP method GET is not supported by this URL" Watch "HTTP Status 405 - HTTP method GET is not supported by this URL" New topic
Author

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

Sapumal Bandara
Greenhorn

Joined: Oct 29, 2013
Posts: 26

Guys please help me with this.. when I try to run my servlet on server the above error occured.. As my code is about sending and receiving username and password I didn't use GET method. what should I do? Any help is much appreciated.

Below are my servlet class and index.html files.

Servlet class




Index.html



Regards,
Sapumal.




Be you.. not someone else.. in everything you do..
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 826
    
  13

I don't think your request is going where you think it's going. That "action=login" is not going to get you there. Do some searching on that form element and what the action attribute should look like.

btw, I assume this code is just an exercise or homework and not something that's ever going to be used in production. If you are really planning on writing your own login security then we need to have a serious talk.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
Your class extends HttpServlet - HttpServlet provides some basic methods plus stubs for all of the HTTP methods: GET, POST,PUT,DELETE. These stubs ALL respond with that "not supported" message. You the programmer must supply an overriding doGet method if you want your servlet to respond to the GET method.

Bill
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 219

@OP - can you please show your web.xml file.? or else can you annotate the servlet with "url pattern"?


OCPJP
Sapumal Bandara
Greenhorn

Joined: Oct 29, 2013
Posts: 26

Thanks people for every piece of advice.. After overriding doGet() the problem solved! i called doPost within doGet().
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 888
    
    9
Sapumal Bandara wrote:Thanks people for every piece of advice.. After overriding doGet() the problem solved! i called doPost within doGet().

Where is the doGet getting called from? The form you posted is trying to use the post method.
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 826
    
  13

Sapumal Bandara wrote:Thanks people for every piece of advice.. After overriding doGet() the problem solved! i called doPost within doGet().


That's not a fix; it's an ugly hack. You still haven't fixed the issue, which is, why is the server seeing a GET request when you are sending a POST?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
Now for the 10,000 foot view:

According to the standard view of HTTP methods, GET and POST are not equivalent!

Treating them as equivalent has resulted in much bad architecture - unfortunately all over the web, but still bad architecture.

You will see references to RESTful architecture for web services. A RESTful architecture pays close attention to the proper use of the various HTTP methods.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HTTP Status 405 - HTTP method GET is not supported by this URL
 
Similar Threads
error to login page
How to fill select list from database table
Login code problem
Jsp Login Page Problem
'The requested resource is not available' error