title: How to make an option selected from a dropdown list in jsp?
body: <p>In my project. I want to populate the drop down list on a jsp from a database.</p>
  
  <pre><code>&lt;select id="names" name="names"&gt; &lt;c:forEach items="${names}" var="names"&gt;
          &lt;option&gt;&lt;c:out value="${names}"/&gt;&lt;/option&gt;
      &lt;/c:forEach&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The <code>${names}</code> is a list of names from the database. I want to select an option dynamically in the drop down list. Suppose there are three names in the database Rohan, Dean, Justin. If Dean is logged, i want select the option Dean as selected.</p>
  
  <p>I try a code like this but this does not work.</p>
  
  <pre><code>&lt;option value="${names}" ${names == names ? 'selected' : ''}&gt;${names}&lt;/option&gt;
  </code></pre>