title: The Marshaller does not writing to the xml file using JAXB
body: <p>I am learning web services and currently I am learning the JAXB in Tomcate6.0 environment. I have a xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;users&gt;
  &lt;user&gt;
      &lt;email&gt;bill@hotmail.com&lt;/email&gt;
      &lt;name&gt;Bill Gates&lt;/name&gt;
      &lt;password&gt;blahblah&lt;/password&gt;
      &lt;gender&gt;male&lt;/gender&gt;
  &lt;/user&gt;
  &lt;user&gt;
      &lt;email&gt;joe@bloggs.com&lt;/email&gt;
      &lt;name&gt;Joe Bloggs&lt;/name&gt;
      &lt;password&gt;foobar&lt;/password&gt;
      &lt;gender&gt;male&lt;/gender&gt;
  &lt;/user&gt;
  &lt;/users&gt;
  </code></pre>
  
  <p>and this file is located in WEB-INF/users.xml.</p>
  
  <p>I have a class called Blog.java which has two fields:</p>
  
  <pre><code>private Users users;
  private String filePath;
  </code></pre>
  
  <p>and in this class I have this method:</p>
  
  <pre><code>public void setFilePath(String filePath) throws JAXBException, IOException {
      this.filePath = filePath;
  
      JAXBContext jc = JAXBContext.newInstance(Users.class);
      Unmarshaller u = jc.createUnmarshaller();
  
      FileInputStream fin = new FileInputStream(filePath);
      this.users = (Users)u.unmarshal(fin);
      fin.close();
  }
  </code></pre>
  
  <p>to set the path and users.</p>
  
  <p>And this method:</p>
  
  <pre><code>public void saveUser(String filePath) throws JAXBException, FileNotFoundException {
        // Boilerplate code to convert objects to XML...
        JAXBContext jc = JAXBContext.newInstance(Users.class);
        Marshaller m = jc.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        FileOutputStream fos = new FileOutputStream(filePath);
        m.marshal(users, fos);
  }
  </code></pre>
  
  <p>to write to a xml file in the "filePath" given.</p>
  
  <p>And finally in my registration page I have gathers user data and went to register the user in another page where I have coded these:</p>
  
  <pre><code>....
  &lt;% String filePath = application.getRealPath("WEB-INF/users.xml");%&gt;
  ....
  User user = new User(....);
  Blog blog = new Blog();
  blog.setFilePath(filePath);
  blog.getUsers().addUser(user);//this is a method in Users class to add a user to a list
  blog.saveUser(filePath);
  ....
  </code></pre>
  
  <p>However, this is not changing the users.xml file in WEB-INF/users.xml at all. Can anyone give me some advice where I have missed.</p>
  
  <p>thank you</p>