title: How to compare two object variables in EL expression language?
body: <p>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:</p>
  
  <pre><code>&lt;select&gt;
      &lt;c:forEach items="${languages}" var="lang"&gt;
          &lt;c:choose&gt;
              &lt;c:when test="${lang}.equals(${pageLang})"&gt;
                  &lt;option value="${lang}" selected&gt;${lang}&lt;/option&gt;
              &lt;/c:when&gt;
              &lt;c:otherwise&gt;
                  &lt;option value="${lang}"&gt;${lang}&lt;/option&gt;
              &lt;/c:otherwise&gt;
          &lt;/c:choose&gt;
      &lt;/c:forEach&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p><code>.equals</code> 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.  </p>
  
  <p>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.</p>
  
  <p>What is the best plan for a quick fix to comparing two strings in EL?</p>
  
  <p><a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html#wp77078" rel="noreferrer">The J2EE 1.4 Tutorial </a></p>