• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to build a web application from where file can be uploaded to the server.

the html page looks like as follows:-




The web.xml file looks like:-



I am usging tomcat 6.

I have written a FileUploaderServlet that writes the file to the server's local directory.
The FileUploaderServlet looks as follows:-




Everything works fine and I am even able to get the file on server. But once the doPost() method of the servlet completes, it gives me

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

Any idea where things are going wrong?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the purpose of the following line in your servlet?
 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops! my bad.

I removed that but the problem persists.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi Swastik,

I have already overridden the doGet and doPost method in the servlet.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nandini,

Just include the <http-method> element inside servlet mapping section, and see if that helps. Do restart the server after making the changes.

 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<servlet-mapping> element in web.xml can contain only <servlet-name> and url-pattern.

The schema doesn't allow me to put http-method tag inside it.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It probably it goes under web resource collection section

http://www.datadisk.co.uk/html_docs/java_app/jboss5/jboss5_securing_web_apps.htm
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not necessary.

Simply implementing doPost() and not calling the super method should be sufficient.
 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:That is not necessary.

Simply implementing doPost() and not calling the super method should be sufficient.


thanks Bear!

That did the trick.

Would you please tell me why the problem occurs when I make the call to super?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The super instances of the doXyz methods specifically issue a response that says that the method is not supported!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic