简体   繁体   中英

Rerunning test in jsp page without reloading page

Is it possible to rerun a <c:choose> block of code as shown bellow without reloading the JSP page?

<c:choose>
    <c:when test="${salary <= 0}">
       Salary is very low to survive.
    </c:when>
    <c:when test="${salary > 1000}">
        Salary is very good.
    </c:when>
    <c:otherwise>
        No comment sir...
    </c:otherwise>
</c:choose>

This would need to be done in the case that the value of salary changed and a different resut needs to be shown.

You cannot rerun the c:choose block without reloading the JSP. The JSP is processed on the server side and then sent to the client. The client only gets the rendered result of the c:choose , not the JSP itself.

When you use JavaScript to update the value, then either repeat the logic in the JavaScript based on the value of salary or request the label via an XMLHttpRequest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM