Hello All,
I am using the Code,as below, to Download a Text File from a particular
Directory on the Server to any where the user need to download it through the
Dialouge box...
But what i Really want to achieve is that the user should not be asked for an
Dialouge box, instead it
should Download the Text file directly to "Desktop"(By Default)...
Is there a way to do so...if yes can anybody help me out with the solution...
<Code>
public HttpServletResponse doDownloadFile(HttpServletRequest
req,HttpServletResponse res)throws ServletException,IOException {
ServletOutputStream stream = null;
res.setContentType("application/binary");
String fname1 = req.getParameter("BusinessId");
String fname2 = req.getParameter("AccountUserId");
String fname =fname1+"-"+fname2+".txt";
res.setHeader("Content-Disposition","inline; filename=\""+fname+"\";");
BufferedInputStream bif = null;
try {
bif = new BufferedInputStream(new FileInputStream
("C:/ABCD/download/XYZ/"+fname));
stream = res.getOutputStream();
byte [] buf = new byte[20480];
int data;
while(( data = bif.read(buf,0,20480)) != -1) {
stream.write(buf, 0, data);
stream.flush();
}
bif.close();
stream.close();
return res;
} catch(Exception e) {
System.out.println("The Exception in MainServlet is :"+e);
}finally {
if (stream != null)
stream.close();
return res;
}
}//end of method
</Code>
Thanks a million in advance,
Regards
Sam
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".