Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
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?

 
Author and ninkuma
Marshal
Posts: 66789
168
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.
 
Rancher
Posts: 1878
15
Android Eclipse IDE Java Java ME
 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Swastik Dey wrote:May be this helps

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



Hi Swastik,

I have already overridden the doGet and doPost method in the servlet.
 
Swastik Dey
Rancher
Posts: 1878
15
Android Eclipse IDE 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: 1878
15
Android Eclipse IDE 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
Posts: 66789
168
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
Posts: 66789
168
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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!