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>

Is there any way to get this to work, or is there a better way to add a class by looking at a JSTL-if-statement?


It's also possible to use an EL expression directly like this:

<div class="${booleanExpr ? 'cssClass' : 'otherCssClass'}">

<c:if test='true'> 
  <c:set value="someclass" var="cssClass"></c:set>
<div class="${cssClass}">
   <p>some other stuff...</p>

That works for me!

<div id="loginById" style="height:<% out.print(instanceClass.booleanMethod()? "250px": "150px");%>">

Need Your Help

Click through an Actor in libGDX

java layout libgdx

I have an overlay in my game that consists of an image of a screen, and a set of buttons that are "on" the screen.