t0mcat
t0mcat

Reputation: 5669

How to code this if structure in JSTL?

can we code the following if condition inside the <c:if test="${}> ?

if((myFlag == true) && (flag1 != null || flag2 != null || flag3 != null))

Upvotes: 0

Views: 155

Answers (2)

JB Nizet
JB Nizet

Reputation: 691645

<c:if test="${myFlag && (flag1 != null || flag2 != null || flag3 != null)}">

Simple, isn't it?

See http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010522 for a reference

Upvotes: 1

nfechner
nfechner

Reputation: 17525

Sure:

<c:if test="${myFlag and (not empty flag1 or not empty flag2 or not empty flag3)}">

PS: Using a null-test to decide a flag instead of true/false is bad style and should be avoided, if possible.

Upvotes: 2

Related Questions