title: How to write a file to resource/images folder of the app?
body: <p>I would like to upload an image and store it on the server, and later to show it with h:graphicImage? I would like to store it in "resources/images" of the app. I am using glassfish 4. Right now, the file goes to "domain1\generated\jsp\FileUpload". Thank you</p>
  
  <p>My form </p>
  
  <pre><code>&lt;h:form id="form" enctype="multipart/form-data"&gt;
          &lt;h:messages/&gt;
          &lt;h:panelGrid columns="2"&gt;
              &lt;h:outputText value="File:"/&gt;
              &lt;h:inputFile id="file" value="#{uploadPage.uploadedFile}"/&gt;
          &lt;/h:panelGrid&gt;
          &lt;br/&gt;&lt;br/&gt;
          &lt;h:commandButton value="Upload File" action="#{uploadPage.uploadFile}"/&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>My bean</p>
  
  <pre><code>@Named
  @ViewScoped
  public class UploadPage {       
      private Part uploadedFile; 
  
      public void uploadFile(){
         File file = File.createTempFile("somefilename-", ".jpg", new File("C:\\var\\webapp\\images"));
      uploadedFile.write(file.getAbsolutePath());
  
      }
  }
  </code></pre>