title: Set the default value of a Drop Down Menu based on data passed in to request
body: <p>I'm trying to set the default value for a drop down menu based on information passed into the page.  So far I have this:</p>
  
  <pre><code>&lt;td&gt;
      &lt;select id="typeDropdown" name="typeDropdown"&gt;
          &lt;option value="val1" selected="selected"&gt;Value 1&lt;/option&gt;
          &lt;option value="val2"&gt;Value 2&lt;/option&gt;
      &lt;/select&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>And that will always have the first value selected.</p>
  
  <p>However, can I do something like this to set the default based on information given to the webpage?</p>
  
  <pre><code>&lt;c:if test="${not empty data}"&gt;
      &lt;c:set var="val" value="${data}" /&gt;
  &lt;/c:if&gt;
  &lt;td&gt;
      &lt;select id="typeDropdown" name="typeDropdown"&gt;
          &lt;option value="val1" &lt;c:if test="val eq 1"&gt;selected="selected&lt;/c:if&gt; &gt;Value 1&lt;/option&gt;
          &lt;option value="val2" &lt;c:if test="val eq 2"&gt;selected="selected&lt;/c:if&gt; &gt;Value 2&lt;/option&gt;
      &lt;/select&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>where <code>data</code> is passed into the page as part of the request.  I understand that the syntax is probably wrong, but I'm more interested in whether not the idea is sound.</p>
  
  <p>EDIT 1:</p>
  
  <p>So that didnt work.  I received the following exception for my efforts:</p>
  
  <pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page /newInterface.jsp at line 127
  
  124: &lt;td&gt;Field 1:&lt;/td&gt;
  125:    &lt;td&gt;&lt;select name="field1"&gt;
  126:        &lt;c:set var="tet" value="val1"/&gt;
  127:        &lt;option value="val1" &lt;c:if test="${old.val eq tet}"&gt;selected="selected"&lt;/c:if&gt;&gt;val1&lt;/option&gt;
  128:        &lt;option value="val2"&gt;val2&lt;/option&gt;
  129:    &lt;/select&gt;
  130: &lt;/td&gt;
  
  
  Stacktrace:
  org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
  org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
  </code></pre>
  
  <p><code>old.val</code> is, for all intents and purposes, the same as that "val" variable from my initial idea.</p>