wood burning stoves 2.0*
The moose likes Servlets and the fly likes Problem in downloading file from Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem in downloading file from Servlet" Watch "Problem in downloading file from Servlet" New topic
Author

Problem in downloading file from Servlet

Madhavan Sundarraj
Greenhorn

Joined: Dec 22, 2004
Posts: 4
I am trying to download a file from server. The open/save dialog window is coming. But, if I click either save or open, in both cases, I got a Explorer error - Internet Explorer can not download <filename> from <servername>

I am using IE 6.0 with SP1

My code goes as follows:

response.setContentType("application/octet-stream");
//response.setContentType("application/download"); // I tried by adding this line and removing both (above) lines ...

response.setHeader("Content-Disposition", "attachment;filename=\"" + strFileName + "\"");
OutputStream servletoutputstream = response.getOutputStream();
byte abyte0[] = new byte[4096];
BufferedInputStream bufferedinputstream = new BufferedInputStream(new FileInputStream(new File(strFileName )));
int i;
while((i = bufferedinputstream.read(abyte0, 0, 4096)) != -1)
servletoutputstream.write(abyte0, 0, i);

bufferedinputstream.close();
servletoutputstream.flush();
servletoutputstream.close();

Anything wrong in my code???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in downloading file from Servlet
 
Similar Threads
getOutputStream() has already been called for this response
unable to download xml file
CANNOT download file from https in IE 6
regarding file downloading
file downoad [browser issue]