• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doPost() not working

 
Ranch Hand
Posts: 43
Notepad Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am learning servlet and following a tutorial. Here we create two servlet which communicates with each other. One servlet take post request from html form and forward the result to other servlet using requestdispatcher applies some more logic and display the result. But when i click on submit button on html fom i get  "HTTP Status 405 - HTTP method POST is not supported by this URL" error. My codes are

basic.html




GrossServlet.java




NetServlet.java



web.xml



Same code run in tutorial but i am getting error, please tell me where i am wrong.


 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For one thing your servlets have to be in a package. Without that you can't even run them, and that probably results in the not-all-that-helpful error message. There may well be other problems but start by fixing that. And don't forget to specify the servlet's fully-qualified name including package in your web.xml file.
 
tushar attar
Ranch Hand
Posts: 43
Notepad Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for a reply, i am currently following a tutorial and in that they didn't used a package.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It must be a really old tutorial.

Anyway, if you were working for an aggressive boss who refused to let you use packages, then you'd have to spend some time trying to work around the requirement for a package name. But you aren't. So just use a package already like everybody else in the world.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

tushar attar wrote:


That's not an override but an overload. The arguments should be HttpServletRequest and HttpServletResponse. Right now there is no doPost implementation, which means the default implementation kicks in. Guess what? That returns a 405 error.

Here's a tip: annotate all your overridden methods with @Override. If it's not a proper override (or interface method implementation), you'll get a compiler error, and you'll know immediately you did something wrong.
 
tushar attar
Ranch Hand
Posts: 43
Notepad Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for pointing out error, I corrected it still no success
 
tushar attar
Ranch Hand
Posts: 43
Notepad Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I just corrected one more error , i created in later stage and it resolved the problem. Thanks Rob your solution did help.
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic