title: read and display a local text file in jsp page
body: <p>I would like to read and display a text file in a <code>JSP</code> page. I found no error in my code but it display a blank after I run it. I have code like this :</p>
  
  <pre><code>&lt;%@page import="java.io.FileInputStream"%&gt;
  &lt;%@page import="java.io.File"%&gt;
  &lt;%@page import="java.io.InputStreamReader"%&gt;
  &lt;%@page import="java.net.URL"%&gt;
  &lt;%@page import="java.io.FileReader"%&gt;
  &lt;%@page import="java.io.BufferedReader"%&gt;
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;Read Text&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;%
              String jspPath = "C:\\log\\";
              String fileName = "log.txt";
              String txtFilePath = jspPath + fileName;
              BufferedReader reader = new BufferedReader(new FileReader(txtFilePath));
              //BufferedReader br = new InputStreamReader(new FileInputStream(txtFilePath));
              StringBuilder sb = new StringBuilder();
              String line;
  
              while((line = reader.readLine())!= null){
                  sb.append(line+"\n");
              }
              System.out.println(sb.toString()); 
          %&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>