Fileupload Component not working

Components, Ajax Framework, Utilities and More.
Post Reply
Posts: 11
Joined: 30 Mar 2010, 08:58

14 Oct 2011, 14:27

anybody help me i serve a lot but did not find any solution about file upload component
i am using simple fileupload component from ... Simple.jsf
my abc.xhtml page is
<h:form enctype="multipart/form-data">

<p:messages showDetail="true"/>

<p:fileUpload value="#{test.file}" mode="simple"/>

<p:commandButton value="Submit" ajax="false"

my bean is with session scop
and i am using primefaces.3.0.M3 version

private UploadedFile file;

public UploadedFile getFile() {
return file;

public void setFile(UploadedFile file) {
this.file = file;
public String upload() {
System.out.println("calling upload");
FacesMessage msg = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}catch(Exception e){
System.out.println("calling upload "+ e.getMessage());
return null;
show Nullpointer Exception
because file object not setted when submit button press
kindly anybody tell me what is going wrong in the above code or is there any additional code is required

Posts: 9
Joined: 07 Oct 2011, 15:34

14 Oct 2011, 15:37

U need 2 mores libs (commons-fileupload-1.1.jar and commons-io-1.4.jar) and add this code in your web.xml...

Code: Select all

        <filter-name>PrimeFaces FileUpload Filter</filter-name>  
        <filter-class> org.primefaces.webapp.filter.FileUploadFilter</filter-class>  
        <filter-name>PrimeFaces FileUpload Filter</filter-name>  
        <servlet-name>Faces Servlet</servlet-name>  
(i'm sorry for my english)

Posts: 11
Joined: 30 Mar 2010, 08:58

15 Oct 2011, 06:34

thanks iurimatos for quick response but i have also added the below code in web.xml and added both of jar in my lib but nothing happen

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 6 guests