title: comparing two valuestack string values in JSP - struts2
body: <p>Thanks in advance for your time. </p>
  
  <p>I need to preselect a radio button if it has a saved value. I basically need to compare 2 strings in the valuestack to determine this. </p>
  
  <p>(I can't use <code>&lt;s:radio</code> at the moment because of some business rules I need to attach based on other input elements in the form).</p>
  
  <p>I tried to do <code>&lt;s:set</code> the value of the saved id inside <code>s:iterate</code> like below and then compare them like below but obviously I didnt get it right.   </p>
  
  <pre><code>&lt;s:set var="savedId" value="%{flag.problemId}"/&gt; 
                &lt;s:iterator value="problemIdList"&gt; 
                      &lt;s:set var="currentId" value='&lt;s:property value="id"/&gt;' /&gt;                   
                          &lt;s:if test="%{#currentId.equals(#savedId)}" &gt;
                                  &lt;input checked="checked" type="radio" name="problemId" id="problemId" value='&lt;s:property value="id"/&gt;'/&gt; &lt;s:property value="description"/&gt; &lt;br/&gt;
                          &lt;/s:if&gt;
                  &lt;s:else&gt;
                      &lt;input type="radio" name="problemId" id="problemId" value='&lt;s:property value="id"/&gt;'/&gt; &lt;s:property value="description"/&gt; &lt;br/&gt;
                  &lt;/s:else&gt;                       
               &lt;/s:iterator&gt;
  </code></pre>
  
  <p>Basically I need to compare the two strings, my code is below. I know I can't compare with equals() like I have below - any ideas? </p>
  
  <p>Thanks a bunch! </p>
  
  <pre><code>&lt;s:set var="savedId" value="%{flag.problemId}"/&gt;  &lt;s:iterator value="problemIdList"&gt;                                 
  &lt;s:if test=' &lt;s:property value="id"/&gt;.equals(&lt;s:property value="savedId"/&gt;) '&gt;
      &lt;input checked="checked" type="radio" name="problemId" id="problemId" value='&lt;s:property value="id"/&gt;'/&gt;            &lt;s:property value="description"/&gt; &lt;br/&gt;
  &lt;/s:if&gt;
  &lt;s:else&gt;
      &lt;input type="radio" type="radio" name="problemId" id="problemId" value='&lt;s:property value="id"/&gt;'/&gt;                     &lt;s:property value="description"/&gt; &lt;br/&gt;
  &lt;/s:else&gt;                       
  </code></pre>
  
  <p></p>
  
  <p>Regards,
  VeeCan</p>