Hello Sir,
I am working
on EJB and using the following Code 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)...without opening the dialog box.. That is i want to Bypass the Opening of DialogBox
step and display a message to the User that the file has been downloaded to the
desktop....
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 = "" != -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>
Any suggestions are greatly
appreciated..
Thanks a million in
advance, Regards Sam |