how can i disable the button by checking the condition in my jsp? If true, the button is enabled; if false, the button is disabled. The condition will check the value of the variable. I know how to disable a button using javascript, but using it together with a condition in jsp is something that I cannot understand. Is it possible?
Try using the JSTL construct as follows:
<input type="button" <c:if test="${variable == false}"><c:out value="disabled='disabled'"/></c:if>">
For more examples, see http://www.ibm.com/developerworks/java/library/j-jstl0211/index.html
el :
el
<input type="button" ${ condition ? 'disabled="disabled"' : ''}/>
:
<input type="button" ${ someVariable eq 5 ? 'disabled="disabled"' : ''}/>
My approach would be something like this:
<c:choose> <c:when test="${condition == true}"> <input type="button" disabled="disabled"/> </c:when> <c:otherwise> <input type="button" /> </c:otherwise> </c:choose>