title: Display String array in spring MVC
body: <p>I am trying to display string array in JSP page.</p>
  
  <p>I have got a test String array in my controller set this to my registration model</p>
  
  <pre><code>String[] test={"ab","cb","sc","ad"};
  registration.setTestArray(test);
  </code></pre>
  
  <p>Now I am trying to display it in jsp Its working fine if I do like this</p>
  
  <pre><code>&lt;tr&gt;
          &lt;c:forEach var="arr" items="${registration.testArray}"&gt;
              &lt;td&gt;${arr} &lt;/td&gt;
          &lt;/c:forEach&gt;
      &lt;/tr&gt;
  </code></pre>
  
  <p>But my problem is I want to display only some of the values from this array like 2nd and 4th index of this array.</p>
  
  <p>I tried like</p>
  
  <pre><code>&lt;tr&gt;
          &lt;c:forEach var="arr" items="${registration.testArray}"&gt;
              &lt;td&gt;${arr[2]} &lt;/td&gt;
          &lt;/c:forEach&gt;
      &lt;/tr&gt;
  </code></pre>
  
  <p>but its throwing an error. This is just a test in my actual project I have long array of array from which I have to display some selected values.</p>
  
  <p>I am thinking of doing this by first process my required values in controller and then display it in jsp. But I am not sure is this the best method. It would be great help if someone suggest me the better way.</p>