validate INPUT TEXT

Hi there,Anybody can help me,just I have a page with 3 numeric field and I need to validate these field, the idea is accept only numeric input, how can I do this?
[176 byte] By [RIMA33a] at [2007-11-26 14:28:24]
# 1
Use NumberFormatException. If exception was thrown then at least one field had non-numeric character.
svagera at 2007-7-8 2:22:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks a lot,look I'm new in this jsp world, can you send me some samples about this issue?
RIMA33a at 2007-7-8 2:22:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

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;

}

svagera at 2007-7-8 2:22:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Hey, how can I use this code, using a javabean or scripter?
RIMA33a at 2007-7-8 2:22:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
You can use this code in JSP page or a servlet.
svagera at 2007-7-8 2:22:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
thanks this really works for me too
Rojara at 2007-7-8 2:22:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...