Issue
I am confused by below behavior. Variable flag is passed from controller to jsp code:
flag: <c:out value="${requestScope.flag}"/>
flag eq 'Y': ${requestScope.flag eq 'Y'}
flag == 'Y': ${requestScope.flag=='Y'}
flag==Y: ${requestScope.flag==Y}
Case 1: Flag is not passed to view (output):
flag:
flag eq 'Y': false
flag == 'Y': false
flag==Y: true
Case 2: Flag with value "Y" is passed to view:
flag: Y
flag eq 'Y': true
flag == 'Y': true
flag==Y: false
Solution
requestScope.flag==Y
means compare with variable Y
which is undefined
Thus when flag is sent, undefined variable isn't equal to flag and return false in second case,
While in first case both are undefined variables, therefore it returns true
Answered By - user7294900