tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Victor Hadianto <vict...@nuix.com.au>
Subject Writing to response's OutputStream cause problem.
Date Thu, 01 May 2003 09:35:37 GMT
Hi List,

I have a servlet that fetches a file from the server and send this to the 
reponse's output stream. The code looks something like this:

<snip>

FileInputStream in = new FileInputStream("/tmp/filename");
byte[] buf = new byte[1024];
int length;
while ((length = in.read(buf)) != -1) {
            response.getOutputStream().write(buf, 0, length);
}

<snip>

Now this is working fine, but I have this irritating problem. Say from the web 
browser my user clicks on the link to retrieve the file:

.../process.do?fileId=5

The first thing that the user see is the dialog box saying:

"You are downloading the file:
../process.do?fileId=5 from hostName

Would you save ... "

After this dialog box I got the "real" dialog box that says:

"Downloading file xyz.zip from hostName ..."

I'm puzzled I don't know what went wrong here. Does anyone have a solution for 
this problem?

Many thanks in advance, any help will be much appreciated.

victor

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message