Answered My own Question.
Thank you Jacob
-----Original Message-----
From: Hookom, Jacob [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 04, 2003 9:04 AM
To: Struts Users Mailing List
Subject: [OT] RE: File Download?
This is what we use for file downloads (Excel/PDF files).
String contentType = this.beanWriter.getContentType();
response.setContentType(contentType);
response.setHeader("Content-Disposition","attachment;filename=\""
+ this.beanWriter.getFileName(request) + "\"");
And have your struts action return null.
-Jacob
-----Original Message-----
From: Stephan Jones [mailto:[EMAIL PROTECTED]
Sent: March 1, 2004 1:42 AM
To: [EMAIL PROTECTED]
Subject: Question about File downlods and letting users save a
downloaded file. I am losing the original file name.
My Problem is with the URL presented when i get prompted to save a file.
I am retreiving files/resources from a database and want to let the users
browse them at will.
The code below works except when i get prompted to Save or Open the file.
The name of the file is the name of my Action Mapping. in this case
Attachments.do
How can i place the file name i saved in the database in the browser.
The Action below it an example from the mailing list.
public final class AttachmentsAction extends eCABaseAction
{
/**
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if
any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
* @exception SessionTimeoutException if the session times out, user
must relog
*/
public ActionForward execute (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception, IOException,
ServletException, SessionTimeoutException
{
Log log = LogFactory.getLog(AttachmentsAction.class);
log.debug("At Template");
checkSession(request);
securityAccess cmap=(securityAccess)mapping;
cmap.validateAccess(request);
int id = 0;
try {
id = Integer.parseInt(request.getParameter("id"));
} catch (NumberFormatException ex) {
throw new NoValidWebData("error.NoWebData.issueNumber.Missing");
}
IeCAService serviceImpl = this.geteCAService();
Attachment attch = serviceImpl.getAttachment(new Integer(id));
response.setContentType(attch.getContentType());
response.setContentLength(attch.getAttachment().length);
ServletOutputStream ostream = response.getOutputStream();
ostream.write(attch.getAttachment());
ostream.flush();
return new ActionForward(null);
}
<action path="/AttachmentGet"
type="com.myplace.AttachmentsAction"
name="AttachmentGet"
scope="request"
validate="false">
<set-property property="accessLevel" value="ASU" />
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]