Hi, read this: http://struts.apache.org/2.0.6/docs/stream-result.html
and this (note that it's to much as for a simple download but that's what i've got): package com.ppp.oko.struts.action.motion.file; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.text.ParseException; import java.util.Map; import javax.servlet.ServletContext; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.interceptor.SessionAware; import org.apache.struts2.util.ServletContextAware; import com.opensymphony.xwork2.ActionSupport; import com.pi.eplatform.suirz.common.DateRepresentation; import com.ppp.oko.logic.MotionFile; import com.ppp.oko.logic.user.Obserwator; import com.ppp.oko.logic.user.User; import com.ppp.oko.persistence.prevayler.Motion; @Result(name="success", type="stream", params={"contentType", "image/jpeg"}) public class ShowAction extends ActionSupport implements ServletContextAware, SessionAware { private static final long serialVersionUID = 1L; private String number; private String date; private long id; private ServletContext sc; private Map<String, Object> sessionMap; public InputStream getInputStream() throws ParseException, FileNotFoundException { Motion motion = ((Obserwator) sessionMap.get(User.class.toString())).getMotion(new DateRepresentation(date), number); MotionFile motionFile = motion.getMotionFile(id); String appPath = sc.getRealPath("."); String pathname = appPath+"/WEB-INF/user/fotki/"+motionFile.getMotionFileName(); return new FileInputStream(new File(pathname)); } public void setNumber(String number) { this.number = number; } public void setDate(String date) { this.date = date; } public void setId(long id) { this.id = id; } @Override public void setServletContext(ServletContext arg0) { this.sc = arg0; } @Override public void setSession(Map<String, Object> map) { this.sessionMap = map; } } Hope that helps, Paweł Wielgus. 2009/6/16 PEGASUS84 <pegasu...@hotmail.it>: > > please > can anyone send me the cplete code to create an action which allows to > download a file > -- > View this message in context: > http://www.nabble.com/download-file-tp24050039p24050039.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org