| 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: 56150
|
|
|
What is the purpose of the following line in your servlet?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
nandini lagunia
Ranch Hand
Joined: May 05, 2009
Posts: 57
|
|
oops! my bad.
I removed that but the problem persists.
|
 |
Swastik Dey
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
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
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
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
Ranch Hand
Joined: Jan 08, 2009
Posts: 1188
|
|
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: 56150
|
|
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: 56150
|
|
|
The super instances of the doXyz methods specifically issue a response that says that the method is not supported!
|
 |
 |
|
|
subject: HTTP Status 405 - HTTP method POST is not supported by this URL.
|
|
|