struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Jones <ste...@redpillconsulting.com>
Subject Question about File downlods and letting users save a downloaded file. I am losing the original file name.
Date Mon, 01 Mar 2004 09:42:22 GMT
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message