If request parameter age
is empty, not a number, or missing altogether, you cannot convert it to a number.
You’ll have to decide what to do in such situation, then do it in the cases mentioned above, i.e.:
- Check the parameter for non-emptiness
- Surround the conversion with
try { ... } catch (NumberFormatException e) { ... }
1
solved Need help! How to solve this exception