Question
How to compare two object variables in EL expression language?
I am creating a drop down list of all languages. The default language selection for the list will be determined by information added by the user:
<select>
<c:forEach items="${languages}" var="lang">
<c:choose>
<c:when test="${lang}.equals(${pageLang})">
<option value="${lang}" selected>${lang}</option>
</c:when>
<c:otherwise>
<option value="${lang}">${lang}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
.equals
doesn't appear to exist in EL. Having had a look here it's suggested I write my own function and then import and use that. As this is a one off tiny thing just for this page I don't want to have to start creating libraries etc just for this. Nor do I want to start creating specialist objects for the servlet to return with this extra info in them.
Only thing I can think to do is to return the actual html for the whole option line from the servlet rather than just the language string, but that strikes me as ugly so I'm hoping there's a more elegant solution.
What is the best plan for a quick fix to comparing two strings in EL?