title: How to create JSF page which displays text log file with lazy loading
body: <p>I want to display JSF page which displays the content of a Glassfish's log file. So far I have done only this:</p>
  
  <pre><code>    import java.io.File;
      import java.io.FileInputStream;
      import java.io.IOException;
      import java.io.Serializable;
      import javax.annotation.PostConstruct;
      import javax.faces.bean.ViewScoped;
      import javax.faces.context.FacesContext;
      import javax.inject.Named;
  
      @Named("GlassfishLogFileController")
      @ViewScoped
      public class GlassfishLogFile implements Serializable
      {
  
          String id;
          String fileData;
  
          // Constructor
          public GlassfishLogFile()
          {
              // Get the ID value 
              try
              {
                  this.id = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id");
              }
              catch (Exception e)
              {
                  this.id = null;
              }
          }
          // Path for Glassfish directory with log files
          String path = "/opt/glassfish3/glassfish/domains/domain1/logs/" + id;
  
          @PostConstruct
          public void redFile()
          {
              File file = new File(path);
  
              try (FileInputStream fis = new FileInputStream(file))
              {
  
                  int content;
                  while ((content = fis.read()) != -1)
                  {
                      // convert to char and display it
                      fileData = fileData + (char)content;
                  }
  
              }
              catch (IOException e)
              {
                  e.printStackTrace();
              }
          }
  
          public String getdata()
          {
              return fileData;
          }
      }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;div id="settingsdiv" style="width:350px; height:400px; position:absolute;  background-color:r; top:20px; left:1px"&gt;
  
      &lt;div id="settingsHashMap" style="width:1050px; height:400px; position:absolute;  background-color:r; top:20px; left:1px"&gt;
  
          &lt;h:form id="form" &gt;
              &lt;p:growl id="growl" showDetail="true" sticky="true" /&gt;
  
              &lt;h:inputTextarea rows="30" cols="50" value="#{GlassfishLogFileController.data}" /&gt;                            
  
          &lt;/h:form&gt;                    
      &lt;/div&gt; 
  
  &lt;/div&gt;       
  </code></pre>
  
  <p>I'm interested is there any possible way to implement lazy loading into the text area which I will use to display the content of the text file. I want to do this because I want to save memory. Log files sometimes can be very memory consuming.</p>
  
  <p>And also I found many examples how to display .pdf documents into JSF page but none of them how to display text document into text area.</p>
  
  <p>Best wishes</p>
  
  <p>P.S I updated the code. Now I get empty input field. No data from the log file is displayed.</p>