how to write uploadphoto in the insert update delete using
struts? write code struts and jsp jdbc



how to write uploadphoto in the insert update delete using struts? write code struts and j..

Answer / k.v.s.ravindrareddy

****************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 ur file......*/
}
}

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More Struts Interview Questions

Can we have multiple struts config files in a single web app?

0 Answers  


What is struts and springs in java?

0 Answers  


What is Portlet???? when,where and why we use it ??

3 Answers   Infotech, Rebaca, Wipro,


how to connect from struts to database through hibernet and where u can modify the class

0 Answers   Polaris,


in struts without integrate hibernate how to use directly explain?

1 Answers   HCL,






What is the difference between Jakarta Struts and Apache Struts? Which one is better to use?

0 Answers  


why servlet is used as controller not JSP?

9 Answers   MCS,


Struts follows which design patterns?

4 Answers   IGT,


why do we use logic tag library in struts?

1 Answers   Polaris,


i have list of values(e.g 100). using logic:iterate, how can i print the multiples of 5th element? how the logic:iterate will understand the multiples of 5.

2 Answers   CTS, TCS,


Will the struts tags support other markup languages such as wml ?

0 Answers  


diffrence between dispatch action and lookupdispatch action write simple web appliction (insert records in database)

8 Answers   Athena Health Care, Symphony, TCS,


Categories