Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sapumal Bandara
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
J. Kevin Robbins
Bartender
Posts: 1726
19
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@OP - can you please show your web.xml file.? or else can you annotate the servlet with "url pattern"?
 
Sapumal Bandara
Ranch Hand
Posts: 31
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks people for every piece of advice.. After overriding doGet() the problem solved! i called doPost within doGet().
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1726
19
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic