I thought it would be fun to use JSTL for some form validation instead of Javascript.
I am trying to make sure a user only enters numbers in a field called AcctNum. Also i
decided to use <fmt:parseNumber /> to test my field. Here's the code:
<c:catch var="parsingError">
<fmt:parseNumber var="Gotcha" value="${param.AcctNum}"/>
</c:catch>
<c:if test="${Gotcha != param.AcctNum}" var="noMatch"/>
Now here's where i run into problems. if i input a string followed by numbers such as
iu789 then my catch statement catches the error and stores the following statement in
in my variable:
javax.servlet.jsp.JspException: In <parseNumber>, value attribute can not be
parsed: "iu789"
This good. Thats what i am trying to do.
Now if i input something like this: 45678uy78 or number followed by a string such as
this: 89087yht then the whole page craps out on me and i get this error from the
server:
org.apache.jasper.JasperException: javax.servlet.jsp.JspException: An error occurred
while evaluating custom action attribute "test" with value "${Gotcha ==
param.AcctNum}": An exception occured trying to convert String "45678uy78" to type
"java.lang.Long" (null) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
My understanding is that my catch statement is supposed to catch this also but it
doesn't. Am I missing something here guys? Please be gentle since i am a novice. TIA