tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reynir Hübner <rey...@hugsmidjan.is>
Subject RE: Writing to response's OutputStream cause problem.
Date Thu, 01 May 2003 09:55:30 GMT
Hi, 

The first thing that comes to mind is response headers, are you setting the correct response
headers ?
For example you should be setting the content-type and content-length headers...

On the name, I guess the browser just doesn't know what file it's going to get untill it starts
downloading it.

I think it's possible to set a header with the file name : 

response.setContentType("application/pdf");
response.addHeader("Content-Disposition","attachment; filename=downloaded.pdf");
Or soemthing like that. 

Check out : http://www.javaworld.com/javaworld/javatips/jw-javatip94.html

Hope it helps, 
-reynir



> -----Original Message-----
> From: Victor Hadianto [mailto:victorh@nuix.com.au] 
> Sent: 1. maí 2003 09:36
> To: tomcat-user@jakarta.apache.org
> Subject: Writing to response's OutputStream cause problem.
> 
> 
> 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
> 
> 

---------------------------------------------------------------------
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