Salaam All!
This servlet works well when I enter the correct data type in the required fields but with wrong entry and blank entry it only shows exception error. So how would I handle this through a message? how to code this?
thanks
If you will check the JavaDocs for java.lang.Integer you will find that parseInt can throw a NumberFormat Exception which will naturally stop execution of your method..
You will have to provide for checking all of the field values that are going to be parsed as integers.
In fact, it would be good practice to check all of the form values for valid values before modifying your database. Yes this will take a lot of coding, no there is no super simple shortcut.
You can try validation for blank entries which looks something like the following before storing your values to the database for the values you receive.Than parse it to Integer and store it to the database.
and for wrong entries ... use if else blocks as per your conditions