JSTL if-statement inside HTML attribute
Is it possible to do something like this in JSTL:
<div class="firstclass<c:if test='true'> someclass</c:if>"> <p>some other stuff...</p> </div> Is there a way to make this work, or is there a better way to add a class if you look at the JSTL-if statement?
<c:if test='true'> <c:set value="someclass" var="cssClass"></c:set> </c:if> <div class="${cssClass}"> <p>some other stuff...</p> </div> It is also possible to use the EL expression directly like this:
<div class="${booleanExpr ? 'cssClass' : 'otherCssClass'}"> </div> It works for me!
<div id="loginById" style="height:<% out.print(instanceClass.booleanMethod()? "250px": "150px");%>">