This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I saw nothing wrong at first glance.
I copied and pasted your code into my Eclipse, and tested with Tomcat 7.
It worked fine for me (as long as I enter a valid number in the number field that is)
For debugging I would suggest inspecting the request parameter values coming into your servlet - via logging statements or maybe debugging through it.
Check out what the value of the request parameter "number" actually is.
@binu: yes the class attribute 'num' is differently named to the bean property 'number'. However properties of a bean are declared by getter/setter methods, and those are getNumber/setNumber, therefore the bean property is properly 'number'. I do agree this can potentially be confusing, but its completely above board.
My other feedback is along the general code style line
- java class names should start with a capital letter. ie BeanController not beanController.
Thanks for the replies, the problem is now solved. Didn't quite get where the error had occured, I just re-wrote(or is it called re-coded ) the whole app and it ran fine. Maybe I should take the advice of my teachers and switch over to an IDE.