You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Sales <sa...@sealsco.com> on 2002/10/03 17:09:36 UTC

tag

Hello,
I'm having trouble with the <html:file> tag...

Here's a snippet of my jsp:

<html:form method="POST" action="/saveAction.do"
enctype="multipart/form-data">
    <html:file property="file"/>
...
</html:form>

I've also tried the <html:file> tag using the accepts attribute,
accepts="java.io.File", and
accepts="java.io.String",
with, of course, the corresponding property in the actionForm set to the
correct type.

Every time the form is submitted, I get a Servlet Exception:
BeanUtils.populate and ArgumentTypeMismatchException.
Am I missing something here?  Should the type of the upload actionForm
property be File? String?  something else?

If anyone knows of any documentation out there about this, I'd appreciate
it.

Thanks,
Matt


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: tag

Posted by Joe Germuska <Jo...@Germuska.com>.
At 11:09 AM -0400 2002/10/03, Matt Sales wrote:
>Hello,
>I'm having trouble with the <html:file> tag...
>
>Here's a snippet of my jsp:
>
><html:form method="POST" action="/saveAction.do"
>enctype="multipart/form-data">
>     <html:file property="file"/>
>...
></html:form>
>
>I've also tried the <html:file> tag using the accepts attribute,
>accepts="java.io.File", and
>accepts="java.io.String",
>with, of course, the corresponding property in the actionForm set to the
>correct type.
>
>Every time the form is submitted, I get a Servlet Exception:
>BeanUtils.populate and ArgumentTypeMismatchException.
>Am I missing something here?  Should the type of the upload actionForm
>property be File? String?  something else?

something else: org.apache.struts.upload.FormFile

Struts uses a user-configurable implementation of type 
org.apache.struts.upload.MultipartRequestHandler as a factory which 
produces an implementation of FormFile from the HttpServletRequest. 
You rarely have to worry about this detail, but you can set an 
alternative MultipartRequestHandler in the <controller> section of 
your struts-config.xml file.

All you really care about is that when you get the ActionForm in your 
Action, it has a property of type FormFile.

Hope that helps.

Joe

-- 
--
* Joe Germuska    { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get 
glazed, they go white, their hands tremble.... As I watch them I 
often feel that a dope peddler is a gentleman compared with the man 
who sells records."
	--Sam Goody, 1956

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: tag

Posted by Thomas Eichberger <we...@java.at>.
What I do:

JSP file:

<html:form method="post" action="/upload" enctype="multipart/form-data" >
<table border="0" cellpadding="0" cellspacing="0" width="100%">
                 <tr>
                   <td colspan="5"><html:file property="theFile" /></td>
                   <img src="picts/blind.gif" width="30" height="1" border="0">
                   <td><html:submit value=" Go " /></td>
                 </tr>
</table>
</html:form>



UploadActionForm:

protected FormFile theFile;

with get/set methods




UploadAction:perform:

if ( file != null )
{
...
stream = file.getInputStream();

zipFile = new File( user.path, user.kurzname + "-upload.zip" );
bos = new BufferedOutputStream( new FileOutputStream( zipFile ) );

int bytesRead = 0;
int count = 0;
byte[] buffer = new byte[ 8192 ];
while ( ( bytesRead = stream.read( buffer, 0, 8192 ) ) != -1 )
{
bos.write(buffer, 0, bytesRead);
count += bytesRead;


and so on...



At 11:09 03.10.2002 -0400, Matt Sales wrote:
>Hello,
>I'm having trouble with the <html:file> tag...
>
>Here's a snippet of my jsp:
>
>enctype="multipart/form-data"> ... I've also tried the tag using the 
>accepts attribute, accepts="java.io.File", and accepts="java.io.String", 
>with, of course, the corresponding property in the actionForm set to the 
>correct type. Every time the form is submitted, I get a Servlet Exception: 
>BeanUtils.populate and ArgumentTypeMismatchException. Am I missing 
>something here? Should the type of the upload actionForm property be File? 
>String? something else? If anyone knows of any documentation out there 
>about this, I'd appreciate it. Thanks, Matt -- To unsubscribe, e-mail: For 
>additional commands, e-mail: