A colleague gave me a nice file upload Servlet to use; it uses the jakarta commons file upload classes.

I am trying to convert it to a Struts Action class.

Converting the Servlet's doPost method to work in the Action class has not been a problem. The problem is with the source JSP.

If I use html:form/html:file in the source JSP, the upload does not work -- DiskFileUpload.parseRequest returns zero FileItems.

<!-- doesn't work -->
<html:form action="/upload" enctype="multipart/form-data">
 <html:file property="theFile"/>
</html:form>

Even if I change the html:file tag to a regular HTML input tag, and use a form bean that is just an empty class, it still doesn't work.

<!-- doesn't work -->
<html:form action="/upload" enctype="multipart/form-data">
 <input type="file" name="theFile"/>
</html:form>

If I change the html:form tag to be a regular HTML form tag, and change my struts-config action mapping so that it doesn't associate a form bean at all, everything works -- DiskFileUpload.parseRequest now returns 1 FileItem.

<!-- combined with a no-form action, works -->
<form action="/context/upload" method="POST" enctype="multipart/form-data">
 <input type="file" name="theFile"/>
</form>

I assume that using a form bean at all is screwing this up, but I'm perhaps too tired to understand why. I couldn't really surmise by looking at the upload example that comes with Struts, as it appears to use a different technique for the upload implementation (not DiskFileUpload, etc.).

How can I make the source JSP work with my Action class and at the same time use the struts tags and an associated form bean, so that I can take advantage of validation, etc.?

Thanks,
Erik





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to