Hi,

You can use JavaScript and check the fields on submit. Using something like:
var check = pareseInt(document.form.field....);
if (isNaN(check)) {alert("Enter a number! ");}

or with JSP
try {
int age = Interger.parseInt(request.getParameter("age"));
bean.setAge(age);
}
ctach (NumberFormatException e) {
   error ="Age not a number!";
}


So you cant use the setProperty tags to set the bean because it will use
parseInt but not catch the exception for you.

/Nils
>From: BERWART Thierry Reply-To: A mailing list about Java Server Pages
>specification and reference To: [EMAIL PROTECTED] Subject: How can
>I catch an JSP error ???? Date: Thu, 5 Apr 2001 16:06:32 +0200
>
>Hello,
>
>I have a jsp which filled a bean with 3 variables : a name, an address
>email and an age.
>
>This is a part of my JSP :
>
>
>
>
>
>
>
>
>
>
>


>Hello
>

>please enter your name and your email ...
>
>
>Name :
>
>
Email :
>
>
Age :
>
>


>
>...
>
>
>in my bean, the variable is defined as an int. And so, when the user enter
>a string, I got an org.apache.jasper.JasperException ...
>
>My question is : is it possible to catch this exception and display an
>error message like " the age field must be numeric" ... ???
>
>Thanks
>
>Thierry
>
>This is my bean :
>
>import java.util.*; public class test_tbe { private String
>name=null,email=null; private int age;
>
>public test_tbe() { }
>
>public String getName() { return email; }
>
>public int getAge() { return age; }
>
>public void setName(String p_name) { name = new String(p_name); }
>
>public void setEmail(String p_email) { email = new String(p_email); }
>
>public void setAge(int p_age) { age = p_age; }
>
>}
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set
>JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at:
>
>http://java.sun.com/products/jsp/faq.html
>http://www.esperanto.org.nz/jsp/jspfaq.html
>http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to