Can JSP client download files directly to a default loc without "saveas"?

i don't want the browser user to be aware of the file's downloading. So, how should my JSP be modified to fullfill that functionality?

<%@page language="java" import="java.net.*,java.io.*" pageEncoding="gb2312"%>

<%response.reset();

response.setContentType("application/x-downloaddfdfdfdfdfdfdfdfd");

System.out.println(this.getClass().getClassLoader()

.getResource("/").getPath());

String filenamedownload = "f:/exampleDCI_1.xml";

String filenamedisplay = "exampleDCI_1.xml";

filenamedisplay = URLEncoder.encode(filenamedisplay, "UTF-8");

response.addHeader("Content-Disposition", "attachment;filename="

+ filenamedisplay);

OutputStream output = null;

FileInputStream fis = null;

try {

output = response.getOutputStream();

fis = new FileInputStream(filenamedownload);

byte[] b = new byte[1024];

int i = 0;

while ((i = fis.read(b)) > 0) {

output.write(b, 0, i);

}

output.flush();

} catch (Exception e) {

System.out.println("Error!");

e.printStackTrace();

} finally {

if (fis != null) {

fis.close();

fis = null;

}

if (output != null) {

output.close();

output = null;

}

}

%>

[1306 byte] By [Lyricsa] at [2007-10-3 1:33:17]
# 1
The way files are handled is controlled through the browser.If it were possible to 'push' files to a machine with no browser control then your pc would be infested with viruses and spyware.
angrycata at 2007-7-14 18:31:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
yeah, you are right. but we both know that, in the windows media player9's media guide, you click one of the music in the browser and the player is playing the music automaticly. Can JSP do things like that?
Lyricsa at 2007-7-14 18:31:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

> yeah, you are right. but we both know that, in the

> windows media player9's media guide, you click one of

> the music in the browser and the player is playing

> the music automaticly. Can JSP do things like that?

That comparison is flawed. The equivalent would have been the media player playing songs on its own :). Remember you still have to click ;)

ram.

Madathil_Prasada at 2007-7-14 18:31:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

yes, the media player does that job. What I want to do is to parse a .xml document in the server using the client's parser. the people handling the client need only click the file in the browser, and donot need to click "save as", etc. the parser can parse the .xml and return the results. how can that be done?

Lyricsa at 2007-7-14 18:31:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...