I am trying to implement the file upload process in my web application using struts2 fileUpload interceptor. below is my code in
index.jsp
<tags:form action="fileUpload" method="post" enctype="multipart/form-data">
   <tags:file name="fileUpload" label="Choose File"/>
   <tags:submit value="Upload"/>     
</tags:form> 
struts.xml
<action name="fileUpload" class="com.hibernate.action.FileUploadAction">
    <interceptor-ref name="fileUploadStack"/>
    <interceptor-ref name="fileUpload">
        <param name="maximumSize">1024000</param>
        <param name="allowedTypes">application/pdf</param>
    </interceptor-ref>
    <result name="success">/viewChapters.jsp</result>
</action>
FileUploadAction.java
public class FileUploadAction extends ActionSupport
{
private File fileUpload;
private String contentType;
private String fileName;
private String destPath;
/// setter and getter methods
 public String execute()
{
    destPath="C:\\WebPortal_testing";
    try
    {
        System.out.println("Source File Name:"+fileUpload);
        System.out.println("Destination File Name:"+fileName);
        File destFile= new File(destPath,fileName);
        FileUtils.copyFile(fileUpload, destFile);
    }
    catch(IOException exception)
    {
        exception.printStackTrace();
        return ERROR;
    }
    return SUCCESS;
 }
when I select a pdf file in the index.jsp page and click on upload button it is giving null value to the fileUpload field of the action class.
I am executing the application in debug mode and gave this
System.out.println("Source File Name:"+fileUpload);
to check what it is returning and I am getting null.
 
     
    