Thanks Daniel.  Almost missed it.  Will give it a try and let you know.

Thinh

-----Original Message-----
From: Daniel WAMARA 2 [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 14, 2001 2:54 AM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: Files download


I know none but I made an application doing that, all you have to do is to
set up the content type of the response. Here's the code I made for :

public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
{
    HttpSession session = request.getSession();

    try
    {
        <some codes here>
        String username     = getUser(request);
        <some codes here>
        String filetoget     = request.getParameter("filetoget");
        response.setContentType("text/html");
        response.setHeader("Content-disposition", "attachment; filename="+
filetoget);
        BufferedOutputStream bos = new
BufferedOutputStream(response.getOutputStream());
        FileInputStream fis = new FileInputStream(new File(filetoget));
        byte[] buffer = new byte[1024];
        int bytes_read;
        while((bytes_read = fis.read(buffer)) != -1)
            bos.write(buffer, 0, bytes_read);
        fis.close();
        bos.close();

    }
    catch(Exception me)
    {
        <some codes here>
    }

    return mapping.findForward("success");
 }



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to