Dynamically group table rows by value
<p>i have two array:</p>

<pre><code>&lt;%String TXTfileArray[] = (String[])request.getAttribute("txt");%&gt;    
&lt;%String sentenceArray[] = (String[])request.getAttribute("sentence");%&gt;
</code></pre>

<p>by using the following:</p>

<pre><code>&lt;body&gt;

&lt;h1&gt;Table of Phone Numbers&lt;/h1&gt;
&lt;table border="1"&gt;

 &lt;tr&gt;
    &lt;th&gt;txt name&lt;/th&gt;
    &lt;th&gt;sentence&lt;/th&gt;
  &lt;/tr&gt;

   &lt;% for (int i=0; i&lt; sentenceArray.length;i++){ %&gt;

  &lt;tr&gt;
    &lt;td&gt; &lt;%=TXTfileArray[i] %&gt;  &lt;/td&gt;    
     &lt;td&gt; &lt;%=sentenceArray[i] %&gt;  &lt;/td&gt;   &lt;%} %&gt; 

   &lt;/tr&gt;


 &lt;/table&gt;
&lt;/body&gt;
</code></pre>

<p>I can get the result as :</p>

<p><a href="https://i.stack.imgur.com/kpjju.png" rel="nofollow"><img src="https://i.stack.imgur.com/kpjju.png" alt="the result i got"></a></p>

<p>so how to change the table, since there is duplicated txt name in the table, how to remove the duplicated txt name. to keep unique txt name in the column (such as merget the cell)</p>

<p>I want to get the result as following.</p>

<p><a href="https://i.stack.imgur.com/R0aXk.png" rel="nofollow"><img src="https://i.stack.imgur.com/R0aXk.png" alt="enter image description here"></a></p>

<p>if can change the output, how to do it in JSTL tags? </p>