Jsp
<s:form action= "DownLoad" method= "POST" >
<s:file name= "FileName"/>
<s:submit value= "Download"/>
</s:form>
Struts.xml
<action name= "DownLoad" class= "an.action.DownLoadLoginAction" method= "DownLoad" >
<result type= "Stream" >
<param name= "ContentType" >image/jpeg</param>
<param name= "Contentdisposition" >attachment;filename=${fileName}</param>
</result>
</action>
downloadaction
Package an.action;
Import Java.io.FileInputStream;
Import java.io.FileNotFoundException;
Import Java.io.InputStream;
Import Com.opensymphony.xwork2.ActionSupport;
public class Downloadloginaction extends Actionsupport {
Private InputStream InputStream;
Private String FileName;
Writing methods
Public String DownLoad () throws filenotfoundexception{
System.out.println (FileName);
inputstream= new FileInputStream ("e:\\" +filename);
return SUCCESS;
}
Public InputStream getInputStream () {
return inputstream;
}
public void Setinputstream (InputStream inputstream) {
This.inputstream = InputStream;
}
Public String GetFileName () {
return fileName;
}
public void Setfilename (String fileName) {
This.filename = FileName;
}
}
SSH File/Image Download (English)