primefaces file upload deployment problem
I m trying to upload a file to my server via primefaces.

Here is index.html

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:p="http://primefaces.prime.com.tr/ui"
           xmlns:f="http://java.sun.com/jsf/core">
      <h:head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
       <title>PrimeFaces Test</title>
       <p:resources />
      </h:head>
         <f:view>
         <h:body>
        <h:form id="form" enctype="multipart/form-data" prependId="false">
         <p:growl id="messages" />
         <p:layout style="width:400px;height:200px;">
          <p:layoutUnit position="west" >Left Pane</p:layoutUnit>
          <p:layoutUnit position="center">Right Pane</p:layoutUnit>
         </p:layout>
         <p:fileUpload fileUploadListener="#{bean.processFileUpload}" id="documentToUpload"
                       allowTypes="*.jpg;*.png;*.gif;" description="Images" />
    
        </h:form>
       </h:body>
    </f:view>
    </html>


here is bean.java



    import java.io.FileOutputStream;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.faces.application.FacesMessage;
    import javax.faces.bean.ManagedBean;
    import javax.faces.context.FacesContext;
    import javax.faces.event.AbortProcessingException;
    import org.primefaces.event.FileUploadEvent;
    import org.primefaces.model.UploadedFile;

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    /**
     *
     * @author yakUP
     */
    @ManagedBean(name="bean")
    public class bean {
        private String dosyaisim;
        public void processFileUpload(FileUploadEvent event) throws AbortProcessingException {
          System.out.println("Uploaded: " + event.getFile().getFileName());
    UploadedFile file = event.getFile();
    byte[] readData=file.getContents();
    dosyaisim=file.getFileName();
    imgSave(readData,dosyaisim);
    FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
    FacesContext.getCurrentInstance().addMessage(null, msg);
    }
    public void imgSave( byte[] readData,String dosyaisim )
    {
    try {
    FileOutputStream fos = new FileOutputStream("images"+dosyaisim);
    fos.write(readData);
    fos.flush();
    fos.close();
    } catch (Exception ex) {
    Logger.getLogger(bean.class.getName()).log(Level.SEVERE, null, ex);
    }
    }
    }



and here is web.xml 



    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>faces/index.xhtml</welcome-file>
        </welcome-file-list>
        <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>
            org.primefaces.resource.ResourceServlet
        </servlet-class>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
        <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
    </context-param>
    <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    <init-param>
      <param-name>thresholdSize</param-name>
      <param-value>512000</param-value>
    </init-param>
    <init-param>
      <param-name>uploadDirectory</param-name>
      <param-value>/temp</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    </web-app>



but in netbeans / tomcat it is not deployed i dont know what is wrong ?

please help me.

Thanks


primefaces file upload deployment problem
===

I m trying to upload a file to my server via primefaces.

Here is index.html

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:p="http://primefaces.prime.com.tr/ui"
           xmlns:f="http://java.sun.com/jsf/core">
      <h:head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
       <title>PrimeFaces Test</title>
       <p:resources />
      </h:head>
         <f:view>
         <h:body>
        <h:form id="form" enctype="multipart/form-data" prependId="false">
         <p:growl id="messages" />
         <p:layout style="width:400px;height:200px;">
          <p:layoutUnit position="west" >Left Pane</p:layoutUnit>
          <p:layoutUnit position="center">Right Pane</p:layoutUnit>
         </p:layout>
         <p:fileUpload fileUploadListener="#{bean.processFileUpload}" id="documentToUpload"
                       allowTypes="*.jpg;*.png;*.gif;" description="Images" />
    
        </h:form>
       </h:body>
    </f:view>
    </html>


here is bean.java



    import java.io.FileOutputStream;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.faces.application.FacesMessage;
    import javax.faces.bean.ManagedBean;
    import javax.faces.context.FacesContext;
    import javax.faces.event.AbortProcessingException;
    import org.primefaces.event.FileUploadEvent;
    import org.primefaces.model.UploadedFile;

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    /**
     *
     * @author yakUP
     */
    @ManagedBean(name="bean")
    public class bean {
        private String dosyaisim;
        public void processFileUpload(FileUploadEvent event) throws AbortProcessingException {
          System.out.println("Uploaded: " + event.getFile().getFileName());
    UploadedFile file = event.getFile();
    byte[] readData=file.getContents();
    dosyaisim=file.getFileName();
    imgSave(readData,dosyaisim);
    FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
    FacesContext.getCurrentInstance().addMessage(null, msg);
    }
    public void imgSave( byte[] readData,String dosyaisim )
    {
    try {
    FileOutputStream fos = new FileOutputStream("images"+dosyaisim);
    fos.write(readData);
    fos.flush();
    fos.close();
    } catch (Exception ex) {
    Logger.getLogger(bean.class.getName()).log(Level.SEVERE, null, ex);
    }
    }
    }



and here is web.xml 



    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>faces/index.xhtml</welcome-file>
        </welcome-file-list>
        <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>
            org.primefaces.resource.ResourceServlet
        </servlet-class>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
        <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
    </context-param>
    <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    <init-param>
      <param-name>thresholdSize</param-name>
      <param-value>512000</param-value>
    </init-param>
    <init-param>
      <param-name>uploadDirectory</param-name>
      <param-value>/temp</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    </web-app>



but in netbeans / tomcat it is not deployed i dont know what is wrong ?

please help me.

Thanks

