I am trying to compare two values : one from session and anther from iterator
<s:iterator value="themes" status="currentRecord">
<s:if test="%{usertheme}) == %{themeName}">
<td align="center" bgcolor="red">
</s:if>
<s:else>
<td align="center" bgcolor="green">
</s:else>
</s:iterator>
But I am unable to compare my values, please can you tell me where I am doing mistakes ?
%{}
should be put (if necessary) around all the statement, not in the middle.For Strings you should use
.equals
,.equalsIgnoreCase
,.contains
,.indexOf
etc... Not==
.Change to this:
this works too:
(Not an answer, but two suggestions, and I needed formatting; Andrea's answer is correct.)
For the sanity of yourself and those that follow, turn that chunk of JSP into a single line:
Consider using theme-named CSS instead of inline CSS and avoid it completely, roughly:
(Assuming themes named "theme1", "theme2", "theme3", but that's not relevant.)
It'd be nicer to move the style info "up" a level, e.g.,
table.theme1 td
, but you get the idea. Doing so allows a lot of flexibility in where the theme info comes from and so on.