• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

multiple fie upload with same html field name

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic