In Struts 1.2.8 we have DownloadAction  

write a class that extends extends DownloadAction 

implement folloing meyhod
---------------------------------
import org.apache.struts.actions.DownloadAction;
public class TestDownloadAction extends DownloadAction  {
  protected StreamInfo getStreamInfo(ActionMapping mapping,
            ActionForm form, HttpServletRequest request,
            HttpServletResponse response)
            throws FileNotFoundException,CAcsException,Exception {


 File file  = new File("c:\\test.csv");
     
        
     
        strContentType="text/csv"; // set MIME type for csv file

  return new FileStreamInfo(strContentType, file);

}//end of getStreamInfo
}//end of TestDownloadAction  class


-----Original Message-----
From: Prithivirajan Dhamodharan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 27, 2007 3:56 PM
To: Struts Users Mailing List
Subject: Re: How to make the file to download when clicking on a link


follow the below steps

For HttpServletResponse set the

     response.setContentType(".....") ;
     response.setHeader("Content-Disposition","attachment;filename=\"" + s2
+ "\"")

//s2-- is file
    if required set Pragma & cache-control in header.

 name
     response.setContentLength()  //file length;

Get the output  stream of HttpServleResponse ,
     bufferedoutputstream = new BufferedOutputStream(httpservletresponse
                    .getOutputStream());

Write the content and close the stream.


On 2/27/07, Satheesh <[EMAIL PROTECTED]> wrote:
>
> How to make the file to download when clicking on a link using JSP...
>
> Please send me the code...
>


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

Reply via email to