title: How To Read and print text file data once in My Code Keeps On printing it JSP?
body: <p>hi i am new to jsp i ahve written code that prints data from text file but it keeps on printing it my code is,</p>
  
  <p>files that i imported are,</p>
  
  <pre><code> &lt;%@page language="java" import="java.io.BufferedReader"%&gt;
      &lt;%@page language="java" import="java.util.*"%&gt;
      &lt;%@page language="java" import="java.util.ArrayList"%&gt;
      &lt;%@page import="java.io.FileReader"%&gt;
  
   try
                                 {
              String strpath="/var/test.log";
                ArrayList rows = new ArrayList();
  
    FileReader fr = new FileReader(strpath);
    BufferedReader br = new BufferedReader(fr);
  
    String currentRecord;
    while((currentRecord = br.readLine()) != null)
  rows.add(currentRecord);
    br.close();
    while (rows!=null)
             {
              out.println(rows);
                         }
  
  
  
                                 }
  
          catch(IOException e){
  
          out.print(e.getMessage());
  
          }
  </code></pre>
  
  <p>while i have text file location mention in the code and it contains text in this format,</p>
  
  <pre><code>[Red] apple is red
  [Orange] orange is orange
  [yellow]mango is yellow
  </code></pre>
  
  <p>my code keep on printing it how to fix it ?</p>
  
  <p>if i want to use "rows.add(currentRecord.split("["));"</p>
  
  <p>inorder to print data as similar as in the file then how it would be i used it but it gave errors.. .</p>
  
  <p>Hopes for your suggestions .. .</p>
  
  <p>Thanks in Advance</p>