aspose file tools*
The moose likes Struts and the fly likes FileUploading in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "FileUploading in struts" Watch "FileUploading in struts" New topic
Author

FileUploading in struts

abinash das
Ranch Hand

Joined: Apr 26, 2008
Posts: 52
hi,
i m getting error while trying to upload a file in struts based application
can anybody help.

Error I m getting is

exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


root cause

java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Please post your JSP and corresponding ActionForm bean.


Merrill
Consultant, Sima Solutions
abinash das
Ranch Hand

Joined: Apr 26, 2008
Posts: 52
Jsp Page:

<html:form action="test" method="post" enctype="multipart/formdata">
<html:file property="resume"/>
<html:submit/>
</html:form>

config.xml:

<struts-config>

<form-beans>
<form-bean name="form" type="com.lara.again.TestForm"/>
</form-beans>



<action-mappings>

<action path="/test"
name="form"
type="com.lara.again.TestAction">
<forward name="uploaded" path="/uploaded.jsp"/>

</action>
</action-mappings>


</struts-config>

ActionForm:

package com.lara.again;

import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;

public class TestForm extends ActionForm
{
private FormFile resume;

public FormFile getResume() {
return resume;
}

public void setResume(FormFile resume) {
this.resume = resume;
}

}
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In your html:form tag, the enctype attribute must be multipart/form-data instead of multipart/formdata.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileUploading in struts