JSTL praseNumber

I am trying to test using JSTL, if a variable is a number, but it dont work, even if the var is a number, it still go to the if statement that says its not a number. what can be wrong?

<c:if test="${srcType == 'refNo'}">

<c:set var="srcTypeTemp" value="${srcType}"/>

<c:catch var="error">

<fmt:parseNumber var="empNumber" value="${srcTypeTemp}" />

</c:catch>

<c:if test="${not empty error}">

<jsp:forward page="/internal/mois/feedbackAdmin/home.html"/>

</c:if>

<c:if test="${empty error}">

<c:set var="srcSQL" scope="page">${"ok"}</c:set>

</c:if>

</c:if>

[717 byte] By [Reniera] at [2007-10-3 1:25:46]
# 1

Well take a look at your logic here:

<c:if test="${srcType == 'refNo'}">

<c:set var="srcTypeTemp" value="${srcType}"/>

<fmt:parseNumber var="empNumber" value="${srcTypeTemp}" />

which is like saying

if (srcType.equals("refNo")){

empNumber = Integer.parseInt(srcType)

}

if the variable "srcType" is the string 'refNo' then try parsing it as a number.

Obviously it is NOT a number, because you just checked to see if it was the String 'refNo'

Maybe you need to get your srcTypeTemp value from another variable?

Cheers,

evnafets

evnafetsa at 2007-7-14 18:23:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...