D
Duncan
Hi
I have the following Struts Action
public class HandleImageAction extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm theForm = (DynaActionForm)form;
FormFile f = (FormFile)theForm.get("image");
if(null == f){
System.out.println("the file is null");
}
else{
System.out.println("the file has " + f.getFileSize() + " bytes available");
}
return mapping.findForward("whatever");
}
}
struts config is
<form-bean name="imageForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="image" type="org.apache.struts.upload.FormFile"/>
</form-bean>
<action path="/handleimage" type="com.foo.images.HandleImageAction" name="imageForm"
scope="session">
<forward ...
</action>
here is my form
<form name="imageform" action="handleimage.do" method="post" enctype="multipart/form-data">
with the file field
<input type="file" name="image">
every time I submit this form the action is called twice.
The first time I get 'the file is null' printed to the console
The second time I get 'the file has 4090771 bytes available' which seems reasonable as this is the
size of the file.
I have read through my (useless) Struts book but it has one line about multipart requests.
I'm sure my other (non multipart) Actions don't execute twice
Anyone know why this is happening ?
Many thanks
Duncan
I have the following Struts Action
public class HandleImageAction extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm theForm = (DynaActionForm)form;
FormFile f = (FormFile)theForm.get("image");
if(null == f){
System.out.println("the file is null");
}
else{
System.out.println("the file has " + f.getFileSize() + " bytes available");
}
return mapping.findForward("whatever");
}
}
struts config is
<form-bean name="imageForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="image" type="org.apache.struts.upload.FormFile"/>
</form-bean>
<action path="/handleimage" type="com.foo.images.HandleImageAction" name="imageForm"
scope="session">
<forward ...
</action>
here is my form
<form name="imageform" action="handleimage.do" method="post" enctype="multipart/form-data">
with the file field
<input type="file" name="image">
every time I submit this form the action is called twice.
The first time I get 'the file is null' printed to the console
The second time I get 'the file has 4090771 bytes available' which seems reasonable as this is the
size of the file.
I have read through my (useless) Struts book but it has one line about multipart requests.
I'm sure my other (non multipart) Actions don't execute twice
Anyone know why this is happening ?
Many thanks
Duncan