title: trying to write data in text file
body: <blockquote>
    <p>i have created a bean class named <strong>User</strong>; its working fine , as its working for setter and getter properties
    and a class <strong>UserIO</strong> as below</p>
  </blockquote>
  
  <pre><code>public class UserIO {
  public static void add(User user, String filepath) throws IOException{
  File file =new File(filepath);
  out.println(user.getEmailAddress()+ " | " +user.getFirstName() + " | " +user.getLastName());
  out.close();}}
  </code></pre>
  
  <blockquote>
    <p>finally i am calling it from a jsp file as below:</p>
  </blockquote>
  
  <pre><code>&lt;% String firstName = request.getParameter("firstName"); 
     String lastName = request.getParameter("lasttName");
     String emailAddress = request.getParameter("emailAddress");
  
     ServletContext sc=this.getServletContext();
     String path =sc.getRealPath("/WEB-INF/EmailList.txt");
  
      User user = new User(firstName, lastName, emailAddress);
      UserIO.add(user, path);
  
     &lt;%= user.getFirstName() %&gt;
  </code></pre>
  
  <blockquote>
    <p>The program is running fine, without any exception. User class is also working, as i can set and get values. But, the data is not being written in the EmailList.txt file(which is in web-inf dir, its path is showing correct when i m using RealPath). I am using Netbeans IDE. Can anyone help me to solve it. 
    moreover in UserIO class i have also tried below code(its not working either:</p>
  </blockquote>
  
  <pre><code> FileOutputStream fos= new FileOutputStream(filepath, true);
  fos.write((user.getEmailAddress()+ " | " + user.getFirstName() + " | " + user.getLastName()).getBytes());
  </code></pre>