I am having trouble getting the page to work. I have my form method to post and my servlet implements doPost()
. However, it keeps showing me that I am not suppo
This happened to me when:
And the form method="POST"
I tried to access the action using the URL directly, without using the form submitt. Since the default method for the URL is the doGet method, when you don't use the form submit, you'll see @ your console the http 405 error.
Solution: Use only the form button you mapped to your servlet action.
If you're still facing the issue even after replacing doGet()
with doPost()
and changing the form method="post"
. Try clearing the cache of the browser or hit the URL in another browser or incognito/private mode. It may works!
For best practices, please follow this link. https://www.oracle.com/technetwork/articles/javase/servlets-jsp-140445.html
It says "POST not supported", so the request is not calling your servlet. If I were you, I will issue a GET (e.g. access using a browser) to the exact URL you are issuing your POST request, and see what you get. I bet you'll see something unexpected.
It's because you're calling doGet()
without actually implementing doGet()
. It's the default implementation of doGet() that throws the error saying the method is not supported.
if you are using tomcat you may try this
<servlet-mapping>
<http-method>POST</http-method>
</servlet-mapping>
in addition to <servlet-name>
and <url-mapping>