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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is apache struts framework?

524


What is the configuration files used in struts?

529


What is struts actionmapping?

526


What are the main classes which are used in struts application?

503


What is the difference between struts1 and struts2?

518






Why do the struts tags provide for so little formatting?

588


Which class of struts is responsible to converts data types from string and vice versa?

667


Explain design patterns which is used in struts?

540


How you will enable front-end validation based on the xml in validation.xml?

575


State the procedure for using forward attribute of link tag’s.

544


How to override the default error message that can come during file uploading process?

578


What is the purpose of @after?

587


How to explain Software Bank Loan descriptions

1903


What is spring and struts in java?

515


What is the purpose of @results annotation?

720