title: Struts File Upload Problem
body: <p>i have problem in file uploading in struts</p>
  
  <p>my jsp file code</p>
  
  <p>
                      
                              <br>
                                      Name Of Candidate
                                      
                              
                              <br>
                                      Candidate Current Designation <br />
                                      
                              
                                                          <br>
                                      Candidate Total Experiance<br />
                                      
                              
                              <br>
                                      Current Salary<br />
                                      
                              
                              <br>
                                      Excpected Salary<br />
                                      
                              
                              <br>
                                      Ready To Relocate<br />
                                      
                              
                              <br>
                                      Education<br />
                                      </p>
  
  <pre><code>                        &lt;/tr&gt;
                          &lt;tr&gt;    
                                  &lt;td&gt;Key Skill In Field&lt;br /&gt;&lt;/td&gt;
                                  &lt;td&gt;&lt;html:text name="GenerateResumeForm" size="35" property="keySkill"/&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;    
                                  &lt;td&gt;Attach Resume&lt;br /&gt;&lt;/td&gt;
                                  &lt;td&gt;&lt;html:file name="GenerateResumeForm" property="attachFile"/&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;    
                                  &lt;td&gt;Job Description&lt;br /&gt;&lt;/td&gt;
                                  &lt;td&gt;&lt;html:textarea name="GenerateResumeForm" cols="27" rows="5" property="jobDesc"/&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;    
                                  &lt;td&gt;&lt;br /&gt;&lt;/td&gt;
                                  &lt;td&gt;&lt;html:submit/&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                  &lt;/table&gt;
                  &lt;/html:form&gt; 
  </code></pre>
  
  <p>my ActionForm is</p>
  
  <p>package com.hrstrides.employer.generateResume;</p>
  
  <p>import org.apache.struts.upload.FormFile;</p>
  
  <p>public class GenerateResumeForm extends org.apache.struts.action.ActionForm {</p>
  
  <pre><code>/**
   * 
   */
  private static final long serialVersionUID = 6895513074470145219L;
  
  private String designation;
  private String experiance;
  private String jobDesc;
  private String currentSalary;
  private String expectedSalary;  
  private String readyToRelocate;
  private String education;
  private String keySkill;
  private FormFile attachFile;
  public String getDesignation() {
      return designation;
  }
  public void setDesignation(String designation) {
      this.designation = designation;
  }
  public String getExperiance() {
      return experiance;
  }
  public void setExperiance(String experiance) {
      this.experiance = experiance;
  }
  public String getJobDesc() {
      return jobDesc;
  }
  public void setJobDesc(String jobDesc) {
      this.jobDesc = jobDesc;
  }
  public String getCurrentSalary() {
      return currentSalary;
  }
  public void setCurrentSalary(String currentSalary) {
      this.currentSalary = currentSalary;
  }
  public String getExpectedSalary() {
      return expectedSalary;
  }
  public void setExpectedSalary(String expectedSalary) {
      this.expectedSalary = expectedSalary;
  }
  public String getReadyToRelocate() {
      return readyToRelocate;
  }
  public void setReadyToRelocate(String readyToRelocate) {
      this.readyToRelocate = readyToRelocate;
  }
  public String getEducation() {
      return education;
  }
  public void setEducation(String education) {
      this.education = education;
  }
  public String getKeySkill() {
      return keySkill;
  }
  public void setKeySkill(String keySkill) {
      this.keySkill = keySkill;
  }
  public FormFile getAttachFile() {
      return attachFile;
  }
  public void setAttachFile(FormFile attachFile) {
      this.attachFile = attachFile;
  }
  public String getCandidateName() {
      return candidateName;
  }
  public void setCandidateName(String candidateName) {
      this.candidateName = candidateName;
  }
  public static long getSerialversionuid() {
      return serialVersionUID;
  }
  private String candidateName;
  </code></pre>
  
  <p>}</p>
  
  <p>and action class is</p>
  
  <p>package com.hrstrides.employer.generateResume;</p>
  
  <p>import java.io.File;
  import java.io.InputStream;</p>
  
  <p>import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;</p>
  
  <p>import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.upload.FormFile;</p>
  
  <p>public class GenerateResumeAction extends Action {</p>
  
  <pre><code>private String name;
  private String designation;
  private String experiance;
  private String currentSalary;
  private String expectedSalary;
  private String relocate;
  private String education;
  private String keySkill;
  private FormFile file;
  private String jobDescription;
  
  public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse responese)throws Exception{
  
      GenerateResumeForm generateResume = (GenerateResumeForm) form;
  
      name = generateResume.getCandidateName();
      designation = generateResume.getDesignation();
      experiance = generateResume.getExperiance();
      currentSalary = generateResume.getCurrentSalary();
      expectedSalary = generateResume.getExpectedSalary();
      relocate = generateResume.getReadyToRelocate();
      education = generateResume.getEducation();
      keySkill = generateResume.getKeySkill();
  
  
      jobDescription = generateResume.getJobDesc();
  
  //  FormFile myFile = generateResume.getAttachFile();
      //System.out.println(myFile.getFileSize());
  
      /*
      GenereateResumeDAO geneResume = new GenereateResumeDAO(name,designation,experiance,
              currentSalary,expectedSalary,relocate,education,keySkill,jobDescription);
      if (geneResume.isGenerated()){
          System.out.println("True");
      }else{
          System.out.println("False");
      }
      */
      return null;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and error like</p>
  
  <p>java.lang.IllegalArgumentException: argument type mismatch
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1773)
      at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
      at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
      at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
      at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
      at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
      at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
      at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
      at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:619)</p>