Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Problem : Upload Files With Struts FreamWork!

  Asked By: Pedro    Date: Mar 30    Category: Java    Views: 1204

i hava a problem with upload files with Struts fream
My JSp Form Is:

<html:form enctype="multipart/form-data"
name="UploadForm" action="/webStruts/sendToBulk.do"
method="POST" >
<html:file property="file" ></html:file>
<Html:submit property="submit" value="upload" />

and my servlet is:

UploadForm is my ForamBean...
but i run this servlet this error ocurred..
IO EXception :Corrupt form data: premature ending

i test this project with JSP/Servlet Model 2 but did
not this error



1 Answer Found

Answer #1    Answered By: Chau Tran     Answered On: Mar 30

I think you created a servlet but you must use the
StrutsAction Servlet in your web.xml and create an
Action class and struts-config.xml (which this new
action sepecified in it with your path sendToBulk.do)

I don't know that you are aware of these issues or
So you can not use a Servlet for your purpose you must
use struts  ActionServlet as shown in this snip of



And the create an Action class and then configure it
in a struts-config.xml file which is placed beside
web.xml in WEB-INF directory and specify in its
configuration your path (for example: sendToBlock) as
shown in the following snip of struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"



<!-- Form Bean Definitions -->
<form-bean name="testForm"


<action path="/sendToBulk"
name="testForm" scope="request"
validate="false" input="/main/test.jsp">


You must configure your struts completely to use its

> Dear mr. dolatshahi!
tnx for u'r answer!
for upload  file with struts i write a :
1- (sendToBulk.do) ActionServlet for upload a file
with struts.
2- create a form bean that have property (FormFile)
with setter and getter Method.
3- create a jsp file that u see it's
code...(Multi-part form)
4- add a commons-upload,jar to classpath.
but when i run my project(for upload file) get this
error : IO EXception :Corrupt form data: premature

however! can i use from FormFile Class that struts is
inroduce to me? (this class have a getInputsetram
method that get to me content of uploaded file)

Didn't find what you were looking for? Find more on Problem : Upload Files With Struts FreamWork! Or get search suggestion and latest updates.