Regular Expressions

Always use PROPER Regular Expression for Validations both in JSP and Servlet.
This saves time, efficiency and Code.

Before passing to the regEx just check the null validation and that's it. Yours all.

public boolean isNumeric(String stringValue) {
if(stringValue != null)
{
Pattern pattern = Pattern.compile( "\\d+" );
Matcher matcher = pattern.matcher(stringValue);
return matcher.matches();
}
else
{
return false;
}
}

RegEx for checking a String is Numeric or not.