How to Download File without Propmting

Hi, My code is able to save file from server to client but it is displaying Save dialog box.

I want the same file to be downloaded without save dialog box . IS there any Way?

My Prog:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

try{

File sendFile= new File("D:/ABC.pdf");

FileInputStream in=new FileInputStream(sendFile);

response.setContentType("application/download");

response.addHeader("Content-Disposition", "attachment;filename="+fileName);

String fileName="test1234.pdf";

response.setContentLength((int)sendFile.length());

ServletOutputStream outputStream =response.getOutputStream();

byte[] buf= new byte[1000];

int length=0;

while ((in != null) && ((length = in.read(buf)) != -1))

{ // System.out.println("Bytes read in: " +Integer.toString(length));

outputStream.write(buf,0,length);

}

}catch(Exception e){}

}

[1030 byte] By [sumit.manhasa] at [2007-11-26 15:22:14]
# 1
I hope not. That would make it real easy to spread viruses, or screw with someones computer.
stevejlukea at 2007-7-8 21:37:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Is there Any way to download the file without asking user to save.
sumit.manhasa at 2007-7-8 21:37:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
No, and it is also not possible to print without asking for permission either (for example). You are not allowed this power because it is far too easy to abuse it.
gimbal2a at 2007-7-8 21:37:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
If you could download it directly, how would you specify where to save it...
jiberisha at 2007-7-8 21:37:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Hello,Can there be any way to save the file only at specific location. User should not have the flexibility to save the file in any different location.Vinayak
VinayakAt080a at 2007-7-8 21:37:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

yes he/she should.

It is not your right at all to limit the user in any way, other than what he can do inside your webpage. Clicking on browser buttons, printing, saving files where he likes, that is all up to the user. All you can do is provide a helpful text that explains what he/she has to do.

Think about this problem like this: the internet is not bound to one platform at all. If you want to limit the user where he can save his data, say c:\downloads, how will this ever work on mac or linux machines which have completely different file systems?

gimbal2a at 2007-7-8 21:37:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
U hav to use Stream Concept for that!!!
sumit.manhasa at 2007-7-8 21:37:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...