Hello All,
I have written a code to download a Text file from Server to Local Disk.But the problem
is that when i click a Button in the JSP page through which the downloading of file is 
done,opens a Dialouge Box with the "Save To Disk " option selected.when i go for the 
Save 
option the Text Field shows me a Wrong Filename("downloadFile.htm")....which is not 
the 
File i want Download.I want to Download "1003-3.txt"....
Also when i go for the "OPEN" option and click on "OK" the Dialouge Box Opens again 
with the "Save To Disk" option selected,when i click on "OK" the Text Field of the 
Dialouge Box Shows the CORRECT Filename("1003-3.txt").....when i click OK the File 
gets DOWNLOADED but with "NO CONTENTS".....

The snippet of code is .....


public HttpServletResponse doDownloadFile(HttpServletRequest req,HttpServletResponse 
res)
throws ServletException,IOException {

String fname = "1003-3.txt";
res.setContentType("application/binary");
res.setHeader("Content-Disposition","attachment; filename=\""+fname+"\";");

ServletOutputStream stream = null;
try {
stream = res.getOutputStream();
BufferedInputStream bif = new BufferedInputStream(new FileInputStream(fname)); 
int data;
while(( data = bif.read()) != -1) {
stream.write(data);
stream.flush(); 
}
bif.close();
stream.close();
return res;
} catch(Exception e) {
}
finally {
if (stream != null)
stream.close();
return res;
}

}




Can Anybody Help me out with the problem....Please it is URGENT!!!!!!
Thanks a MILLION in Advance

==========================================================================To 
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to