Download file from server

Hi

I am using this code thatI got from another post to download a file from server

final ServletOutputStream out = response.getOutputStream();

response.setContentType("application/octet-stream");

BufferedInputStream is = new BufferedInputStream(new FileInputStream(new File("c:/Test.png")));

byte[] buf = new byte[4 * 1024]; // 4K buffer

int bytesRead;

while ((bytesRead = is.read(buf)) != -1) {

out.write(buf, 0, bytesRead);

}

out.flush();

is.close();

out.close();

I am having these problems:

1. Instead of downloding the file, its displaying the file in the same page

2. there is no pop up to cofirm with user if user want to download the file or not

I am using struts (& weblogic).

Thanks in advance

[823 byte] By [Jus55a] at [2007-11-27 11:06:17]
# 1

You need to set the content-disposition header to 'attachment'.

BalusCa at 2007-7-29 13:14:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...