NumberFormatException
occurs when you are trying to convert an illegal value to an int
value. You need to check the value before you are trying to read them as int
value
//Check the `iDisplayStart` parameter is not null
if(request.getParameter("iDisplayStart")!=null)
//do the conversion if it is not null
param.iDisplayStart = Integer.parseInt(request.getParameter("iDisplayStart"))
Note: iDisplayStart
parameter should contain a valid value, which can be parsed into an int
value. otherwise, you will get NumberFormatException
. You can also create an utility method which takes the input value, validate it and do the conversion and return the parsed int
value. If any exception occurs in the utility method, it will return a int
value denoting a failure or error