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){}
}

