You can do that quite easily with JavaScript like,
<form method="get" action="?" onsubmit="return: validate()">
...
</form>
<script language="javascript">
function validate() {
if( isNaN( document.form.p_age.value)) {
return false;
}
return true;
}
</script>
Cheers,
Mark
----- Original Message -----
From: "BERWART Thierry" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 05, 2001 10:03 AM
Subject: How can I catch an JSP error ????
> 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 :
>
> <%@ page import="test_tbe" errorPage="error.jsp" %>
>
> <jsp:useBean id ="test" scope="page" class="test_tbe" />
> <jsp:setProperty name="test" property="name" param="p_name"/>
> <jsp:setProperty name="test" property="email" param="p_email"/>
> <jsp:setProperty name="test" property="age" param="p_age"/>
>
> <HTML>
> <BODY>
> <BR><BR>
> Hello
> <BR>
> please enter your name and your email ...
>
> <FORM METHOD="GET">
> Name :
> <INPUT TYPE="text" name="p_name">
> <BR> Email :
> <INPUT TYPE="text" name="p_email">
> <BR> Age :
> <INPUT TYPE="text" name="p_age">
> <BR><BR>
> <INPUT TYPE="SUBMIT">
> ...
>
>
> 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, send email to [EMAIL PROTECTED] and include in
the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html