Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multiple fie upload with same html field name

 
tikku online
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic