html - JSTL forEach and if code not executing properly -


i wrote code assignment appears not executing properly.

<c:if test="${counter<fn:length(passangername[status.index])}">                  <c:redirect url="confirmbooking.jsp" >                     <c:param name="error" value="invalid data. please try again!"/>                 </c:redirect>         </c:if> 

i printing counter values check if loop working fine or not , during first iteration, seems work fine counter value not being printed in second iteration , forth. know second iteration takes place because can see other stuff printing. result "if" part @ end not working why needs fixed. note: else besides working fine. doing wrong here? please help!

additional note: code working fine if inputs alphabets instance, saurav or john if second input combination of alphabets , numbers, code not work.

<c:set var="alphaupper" value="${['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']}"/> <c:set var="alphalower" value="${['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ']}"/>  <c:foreach begin="0" end="${param.looper-1}" varstatus="status">         <c:set var="counter" value="0"/>         <c:out value="${passangername[status.index]}"/> &nbsp; <c:out value="length: ${fn:length(passangername[status.index])}"/><br>                  <c:foreach var="i" begin="0" end="${fn:length(passangername[status.index])}" step="1">                     <c:foreach var="j" begin="0" end="${fn:length(alphaupper)}" step="1">                         <c:if test="${fn:substring(passangername[status.index], i, + 1)==alphaupper[j] or fn:substring(passangername[status.index], i, + 1)==alphalower[j]}">                             <c:set var="counter" value="${counter=counter+1}"/>                          </c:if>                     </c:foreach>                 </c:foreach>          <c:out value="counter: ${counter}"/><br>               <c:if test="${counter<fn:length(passangername[status.index])}">                      <c:redirect url="confirmbooking.jsp" >                         <c:param name="error" value="invalid data. please try again!"/>                     </c:redirect>             </c:if>           <c:set var="records" value="${records=records+1}"/>  </c:foreach> 


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -