Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: How to make the file to download when clicking on a link

Prithivirajan Dhamodharan

2007-02-27

Replies:

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 <satish@(protected):
>
> How to make the file to download when clicking on a link using JSP...
>
> Please send me the code...
>
©2008 junlu.com - Jax Systems, LLC, U.S.A.