I'm trying to write a condition to jstl if tag,
<c:forEach var="ledg" items="user_ledgers">
<c:if test="${ledg.transactionID == param['trns']}">
<c:out value="${ledg.name}"/>
</c:if>
</c:forEach>
Ledg is an object of ledger class and transactionID is a field of type long.
I found this error while runtime.
javax.el.PropertyNotFoundException: Property 'transactionID' not found on type java.lang.String
I tried to convert transactioID value to String by several ways. But not working
String concatination
<c:if test="${(ledg.transactionID+’’) == param['trns']}">
Using custom tag
<c:set var="equals" scope="page">
<z:doTheyEquals v1="${ledg.transactionID}" v2="${param['trns']}"/>
</c:set>
It also expects String type.
Setting user_ledges to session scope
LedgerDAO ledg = Data.getLedgerDAO();
List ledgers = ledg.getLedgers(u);
session.setAttribute("user_ledgers",ledgers);
getLedgers()
public List<Ledger> getLedgers(User u) {
List ledgers = new ArrayList<Ledger>();
try (Connection conn = pool.getConnection()){
PreparedStatement query = conn.prepareStatement("SELECT * FROM user_ledgers INNER JOIN ledgers ON user_ledgers.l_id = ledgers.id WHERE user_ledgers.u_id=? ORDER BY name ASC;");
query.setString(1,u.getId()+"");
ResultSet rs = query.executeQuery();
while(rs.next()){
Ledger l = new Ledger();
l.setId(rs.getLong(4));
l.setName(rs.getString(5));
l.setLayout(rs.getString(7));
l.setTransactionID(rs.getLong(3));
l.setType(rs.getString(6));
ledgers.add(l);
}
} catch (Exception e) {
e.printStackTrace();
ledgers=null;
}
return ledgers;
}
Any help? Thank you.