aspose file tools*
The moose likes Servlets and the fly likes HTTP Status 405 - HTTP method POST is not supported by this URL. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP Status 405 - HTTP method POST is not supported by this URL." Watch "HTTP Status 405 - HTTP method POST is not supported by this URL." New topic
Author

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

nandini lagunia
Ranch Hand

Joined: May 05, 2009
Posts: 57
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

Joined: Jan 10, 2002
Posts: 60058
    
  65

What is the purpose of the following line in your servlet?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
nandini lagunia
Ranch Hand

Joined: May 05, 2009
Posts: 57
oops! my bad.

I removed that but the problem persists.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

May be this helps

http://www.coderanch.com/t/378707/java/java/Http-method-post-not-supported


Swastik
nandini lagunia
Ranch Hand

Joined: May 05, 2009
Posts: 57


Hi Swastik,

I have already overridden the doGet and doPost method in the servlet.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

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

Joined: May 05, 2009
Posts: 57
<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

Joined: Jan 08, 2009
Posts: 1398
    
    6

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

Joined: Jan 10, 2002
Posts: 60058
    
  65

That is not necessary.

Simply implementing doPost() and not calling the super method should be sufficient.
nandini lagunia
Ranch Hand

Joined: May 05, 2009
Posts: 57
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

Joined: Jan 10, 2002
Posts: 60058
    
  65

The super instances of the doXyz methods specifically issue a response that says that the method is not supported!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP Status 405 - HTTP method POST is not supported by this URL.
 
Similar Threads
How to store a particular data into project file
getting the uploaded filename for downloading
how to upload using html or javascript?
how to upload pdf files to My sql with java
Resource not found