title: JSTL - preselect dropwdown value
body: <p>I have a java variable coming from an external system. I need to preselect the dorpdown based on the value received.</p>
  
  <p>I am trying to test the below code but still not working.</p>
  
  <p>//String myPaymentType = "I";</p>
  
  <p>//Drop down has values as "",I,R,IR</p>
  
  <pre><code>&lt;select name="paymentType" id="paymentType" class="form-control"&gt;
         &lt;c:forEach var="paymentType" items="${paymentTypes}"&gt;
          &lt;option &lt;c:if test='${paymentType.paymentValue == myPaymentType}' &gt;selected&lt;/c:if&gt;
            value="${paymentType.paymentValue}" &gt;${paymentType.paymentDesc}&lt;/option&gt;
        &lt;/c:forEach&gt;
      &lt;/select&gt;                                                       
  </code></pre>
  
  <p>//PaymentType.Java</p>
  
  <pre><code> private String paymentValue;
  private String paymentDesc;
  public PaymentType(String paymentValue, String paymentDesc) {
      super();
      this.paymentValue = paymentValue;
      this.paymentDesc = paymentDesc;
  }
  public String getPaymentValue() {
      return paymentValue;
  }
  public void setPaymentValue(String paymentValue) {
      this.paymentValue = paymentValue;
  }
  public String getPaymentDesc() {
      return paymentDesc;
  }
  public void setPaymentDesc(String paymentDesc) {
      this.paymentDesc = paymentDesc;
  }
  </code></pre>
  
  <p>//PaymentTYpes is an ArraList of PaymentType objects</p>
  
  <pre><code>    PaymentType paymentType1 = new PaymentType("","Select Payment Type");
          PaymentType paymentType2 = new PaymentType("I","Initial");
          PaymentType paymentType3 = new PaymentType("R","Recurring");
          PaymentType paymentType4 = new PaymentType("IR","Intial &amp; Recurring");
          PaymentType paymentType5 = new PaymentType("O","Onetime");
  
          paymentTypes.add(0,paymentType1);
          paymentTypes.add(1,paymentType2);
          paymentTypes.add(2,paymentType3);
          paymentTypes.add(3,paymentType4);
          paymentTypes.add(4,paymentType5);
  </code></pre>
  
  <p>//HTML view source</p>
  
  <pre><code>    &lt;select name="paymentType" id="paymentType" class="form-control"&gt;                       &lt;option  value="" &gt;Select Payment Type&lt;/option&gt;
         &lt;option  value="I" &gt;Initial&lt;/option&gt;
          &lt;option  value="R" &gt;Recurring&lt;/option&gt;
         &lt;option  value="IR" &gt;Intial &amp; Recurring&lt;/option&gt;
         &lt;option  value="O" &gt;Onetime&lt;/option&gt;
        &lt;/select&gt;
  </code></pre>