Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I perform bitwise logic within JSTL if statements?

Tags:

java

jsp

jstl

I have a need to perform a bitwise test within a JSP but can't for the life of me figure out how to do it with EL.

I want to do something like:

<c:if test="${(test & testFor) == testFor}">
  <h3>Test Passed</h3>
</c:if>

Of course I can do it with ordinary JSP syntax:

<% if ((test & testFor) == testFor) { %>
  <h3>Test Passed</h3>
<% } %>
like image 587
Brett Ryan Avatar asked Feb 26 '23 11:02

Brett Ryan


1 Answers

I think bitwise operators are not implemented in JSTL (see here)

You can implement a JSTL function, called bitwiseAnd(int, int) and perform the bitwise test in Java code

like image 192
Bozho Avatar answered Mar 01 '23 23:03

Bozho