It's legal to post one line of code as an example. My guess would be that you might have a doPost method, but that it doesn't override doPost as it should. Instead it overloads it, perhaps with a different parameter list.
Are you sure you are calling the correct servlet from your html/jsp page?
Are you running the code straight of a CD or are you typing the code yourself to run it?
Again really difficult to say what is going wrong - without looking at the code. Maybe if you tell us what is the example you are trying out - someone could help you develop one from scratch. That way you'll learn more and have your own copy righted code
P.S - I really don't think code in a book can be copy righted - especially the small snippets - they are usually too trivial. Not 100% - Just wondering actually - maybe someone could confirm?
don't understand why I needed both the methods for the page to work. Can
Well you dont need it. Each servlet that you write , you would be able to determine to handle POST or GET requests ,
depending on that you can override the methods. but since its not possible to control the user from hitting the servlet
directly( which is GET by default ) , so it would be better to declare both the methods and forward the real work to any one
of the method as pointed in the code above.
Joined: Apr 19, 2008
How is that possible that it can hit GET by default when I have configured into the
form.html the POST method. The form.html is the form I load first and it has POST configured in it and an action that loads the results.jsp page.
And the problem you face with this code is? (expect for the fact that i won't compile without the equal to sign after String c?)
Joined: Apr 19, 2008
The problem I am having is I get this message: Http Post is not supported by this url
Joined: Oct 08, 2006
Your form action is wrong. It should not be the servlet-name, but the url-pattern.
If that doesn't solve the problem, then your classpath is probably a mess. You've another (older) class version which does not implement doPost() somewhere else in the classpath which got precedence in classloading. For example jdk/lib, appserver/lib, etc. Clean up your classpath.