downloading and saving 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/vnd.ms-outlook");

BufferedInputStream is = new BufferedInputStream(new FileInputStream(new File("c:/samplefile/1929312RE_HyCalctest.eml")));

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

3.when i run the servlet directly on browser ,its opening file save dailog.

4.but when i open the servlet through window.open() from jsp page its not opening file dailog ,its just calling servlet and closing window.

Please help me out.....its very important requirement for me

[1074 byte] By [Ramesh_Pappalaa] at [2007-11-27 11:45:49]
# 1

> 1. Instead of downloding the file, its displaying the

> file in the same page

Set the content disposition to attachment.

> 2. there is no pop up to cofirm with user if user

> want to download the file or not

Set the content disposition to attachment.

> 3.when i run the servlet directly on browser ,its

> opening file save dailog.

OK?

> 4.but when i open the servlet through window.open()

> from jsp page its not opening file dailog ,its just

> calling servlet and closing window.

What do you want to do here? Show the file inline? Set the content disposition to inline.

You may find this snippet useful: http://balusc.xs4all.nl/srv/dev-jep-fil.html

BalusCa at 2007-7-29 18:04:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

the file is an .eml file and the file internaly has an attachment ,so i need to ask the user to save or open it...it should prompt the user

Ramesh_Pappalaa at 2007-7-29 18:04:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Set the content disposition to attachment.

BalusCa at 2007-7-29 18:04:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...