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

How does struts2 token work?

0 Answers  


what is the difference between ServletContext and ServletConfig?

4 Answers  


What is struts-default package and what are it’s benefits?

0 Answers  


What is role of action class?

0 Answers  


What is the naming convention for a resource bundle file in struts2?

0 Answers  






What is struts 2 framework in java?

0 Answers  


What are the action classes in struts?

0 Answers  


How to use dispatchaction?

0 Answers  


What is action servlet in struts?

0 Answers  


What is apache struts framework?

0 Answers  


What is discontinuous strut?

0 Answers  


In struts how to use regurlar formbeans using validation framework explain?

1 Answers   TCS,


Categories