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
Same code run in tutorial but i am getting error, please tell me where i am wrong.
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.
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.
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.