Something like this. This code assumes an Integer .
boolean validation=true;
int num=0;
String val=request.getParameter("parameterName");
try {
if (val!=null){
num=Integer.parseInt(val); //NumberFormatException thrown here if not a number
} else {
validation=false;
}
}
catch (NumberFormatException nfe){
validation=false;
}