You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Barłomiej Pawłowski <bp...@supermedia.pl> on 2001/08/03 13:36:25 UTC

problem with upload file

Hi
I have created multipart form:

<%@ page contentType="text/html; charset=ISO-8859-2" %>
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">

<META NAME="Author" CONTENT="Bartlomiej Pawlowski">
<title>Test uploadu</title>
</head>
<body>
<h1>Próba uploadu</h1>
<h2> Konsola administracyjna </h2>
<br>
  <html:form action="/upload" >
   File <html:file property="file" />
   <html:submit>Upload</html:submit>
  </html:form>
</body>
</html:html>
next ActionForm bean:

public class UploadForm extends ActionForm {

    private FormFile myFile;
    public UploadForm() {
    }

    public void setMyFile(FormFile file) {
        this.myFile = file;
    }
    public FormFile getMyFile() {
        return myFile;
    }

}

when I submit this form I receive following exception:
Internal Servlet Error:

javax.servlet.ServletException: BeanUtils.populate
 at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:486)
 at
org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:1910)

 at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1521)
 at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

Root cause:
java.lang.IllegalArgumentException: argument type mismatch
 at java.lang.reflect.Method.invoke(Native Method)
 at
org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:825)

 at
org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:756)

 at
org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:782)

 at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:541)

why?
who can help me?



Re: problem with upload file

Posted by Bar³omiej Paw³owski <bp...@supermedia.pl>.

Bar³omiej Paw³owski wrote:
Thanx, for answer but when I change my form and add
enctype='multipart/form-data' I receive another exception:
Internal Servlet Error:
java.lang.ArrayIndexOutOfBoundsException
at javax.servlet.http.MultipartHandler.readLine(MultipartHandler.java:139) at
javax.servlet.http.MultipartHandler.readLine(MultipartHandler.java:103)
at javax.servlet.http.MultipartHandler.gotoBoundary(MultipartHandler.java:160) at
javax.servlet.http.MultipartHandler.nextPart(MultipartHandler.java:315)
at
javax.servlet.http.HttpUtils.parseMultiData(HttpUtils.java:204)
at org.apache.tomcat.util.RequestUtil.readFormData(RequestUtil.java:137) at
org.apache.tomcat.core.RequestImpl.handleParameters(RequestImpl.java:691)
at org.apache.tomcat.core.RequestImpl.getParameterValues(RequestImpl.java:259)

>  at org.apache.tomcat.core.RequestImpl.getParameter(RequestImpl.java:250)

> at

> org.apache.tomcat.facade.HttpServletRequestFacade.getParameter(HttpServletRequestFacade.java:222)

> Any idea?

>
> Mark Schenk wrote:
>
> > >
> > > Hi
> > > I have created multipart form:
> > >
> > [snipsnip]
> > > <br>
> > >   <html:form action="/upload" >
> > >    File <html:file property="file" />
> >
> > Hi,
> >
> >         the problem is, that you didn't create a multipart form! Change your
> > form tag to read <html:form action='/upload' enctype='multipart/form-data'>.
> > After this the populate will work OK.
> >
> > Mark
> >
> > ----------------------------------------------------------------------------
> > Mark Schenk                     |       Ceci n'est pas une signature
> > Blackboard Project Manager      |
> > Delft University of Technology  |E-mail: M.M.A.Schenk@dto.tudelft.nl
> > Dept.: DTO                      |Phone:  +31 152785448 (85448)
> > Room: LB00.680                  |Fax:    +31 152786359
> > ----------------------------------------------------------------------------
> > -
> >
> > >


Re: problem with upload file

Posted by Bar³omiej Paw³owski <bp...@supermedia.pl>.
Thanx, for answer but when I change my form and add
enctype='multipart/form-data' I receive another exception:

Internal Servlet Error:

java.lang.ArrayIndexOutOfBoundsException
 at javax.servlet.http.MultipartHandler.readLine(MultipartHandler.java:139)
 at javax.servlet.http.MultipartHandler.readLine(MultipartHandler.java:103)
 at javax.servlet.http.MultipartHandler.gotoBoundary(MultipartHandler.java:160)
 at javax.servlet.http.MultipartHandler.nextPart(MultipartHandler.java:315)
 at javax.servlet.http.HttpUtils.parseMultiData(HttpUtils.java:204)
 at org.apache.tomcat.util.RequestUtil.readFormData(RequestUtil.java:137)
 at org.apache.tomcat.core.RequestImpl.handleParameters(RequestImpl.java:691)
 at org.apache.tomcat.core.RequestImpl.getParameterValues(RequestImpl.java:259)
 at org.apache.tomcat.core.RequestImpl.getParameter(RequestImpl.java:250)
 at
org.apache.tomcat.facade.HttpServletRequestFacade.getParameter(HttpServletRequestFacade.java:222)

Any idea?

Mark Schenk wrote:

> >
> > Hi
> > I have created multipart form:
> >
> [snipsnip]
> > <br>
> >   <html:form action="/upload" >
> >    File <html:file property="file" />
>
> Hi,
>
>         the problem is, that you didn't create a multipart form! Change your
> form tag to read <html:form action='/upload' enctype='multipart/form-data'>.
> After this the populate will work OK.
>
> Mark
>
> ----------------------------------------------------------------------------
> Mark Schenk                     |       Ceci n'est pas une signature
> Blackboard Project Manager      |
> Delft University of Technology  |E-mail: M.M.A.Schenk@dto.tudelft.nl
> Dept.: DTO                      |Phone:  +31 152785448 (85448)
> Room: LB00.680                  |Fax:    +31 152786359
> ----------------------------------------------------------------------------
> -
>
> >


RE: problem with upload file

Posted by Mark Schenk <M....@dto.tudelft.nl>.
>
> Hi
> I have created multipart form:
>
[snipsnip]
> <br>
>   <html:form action="/upload" >
>    File <html:file property="file" />

Hi,

	the problem is, that you didn't create a multipart form! Change your
form tag to read <html:form action='/upload' enctype='multipart/form-data'>.
After this the populate will work OK.

Mark

----------------------------------------------------------------------------
Mark Schenk                     |       Ceci n'est pas une signature
Blackboard Project Manager      |
Delft University of Technology  |E-mail: M.M.A.Schenk@dto.tudelft.nl
Dept.: DTO                      |Phone:  +31 152785448 (85448)
Room: LB00.680                  |Fax:    +31 152786359
----------------------------------------------------------------------------
-


>