This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes multiple fie upload with same html field name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multiple fie upload with same html field name" Watch "multiple fie upload with same html field name" New topic
Author

multiple fie upload with same html field name

tikku online
Greenhorn

Joined: Dec 10, 2010
Posts: 1
Hi Please refer the below example as below detailed the multiple upload is done by normal html and the form bean but as I am having my old big size jsp in struts html tags so how can i achieve this .

As I am getting No getter method exception for my setter getter in form bean as below;
..............................my...formbean............................................................
public List getDocPath()
{
log.info("---getDocPath(FormFile docPath)-----");
return this.casestartbean.getUploadFiles();
}
public void setDocPath(int iIndex, FormFile docPath){
this.casestartbean.setUploadFiles(iIndex, docPath);
}
................................................In my JSP....................................................................
<% for(int j=0;j<noofdocs;j++)
{
String fileId = "docPath[";
fileId = fileId.concat(Integer.toString(j)+"]");
%>
<TD align="center" width="5%" rowspan="1"><%=j+1%></TD>
<TD align="center" width="65%">
<html:file property="<%=fileId%>" styleClass="textbox" size="55" onchange="showTable()"/></TD>
...............................................the.....StackTrace...I m getting....................................

javax.servlet.jsp.JspException: No getter method for property docPath[0] of bean org.apache.struts.taglib.html.BEAN
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)
at org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:176)
at com.ibm._jsp._DocumentUpload._jspService(_DocumentUpload.java:410)


===========Example which I refered==============================================================

****************In jsp*********************

<form name="fileupload" enctype="multipart/form-data" method="post"
action="/photos/fileuploadresult">
<tr>
<td >Photo 1</td>
<td ><input type="file" name="uploads[0]" /></td>
</tr>
<tr>
<td >Photo 2</td>
<td ><input type="file" name="uploads[1]" /></td>
</tr>
<tr>
<td>
<input type='submit' name="submit" value="Submit">
</td>
<tr>
</form>
*************** in struts-config.xml*************

<action path="/photos/fileuploadresult"
type="com.uploads.actions.FileUploadAction" name="PhotoUpload"
scope="request" >
<forward name="success" path="/photos/fileuploadresult.jsp" />
</action>


<form-bean name="PhotoUpload" type="com.uploads.forms.FileUploadForm">
</form-bean>

***************in FileUploadForm.java***************

public class FileUploadForm extends ActionForm {

private List formFiles = new ArrayList();

public List getUploads() { return this.formFiles; }

public void setUploads(int iIndex, FormFile formFile){
this.formFiles.add(formFile);
}

}

***************In execute method of FileUploadAction.java***************

FileUploadForm uploadForm=(FileUploadForm)form;
List myFiles =(List) uploadForm.getUploads();
for(int i=0;i<myFiles.size();i++){
if(myFiles.get(i)!=null){
FormFile myFile =(FormFile)myFiles.get(i) ;
/*process your file......*/
}
}

thanks in advance
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: multiple fie upload with same html field name