Member Avatar

Hello Everyone, Im needing a bit of help here. First, Im trying to let client download a file from server and save it on client's pc. When client clicks on button "DOWNLOAD", it will call a servlet that will download the file. Expected outcome is that a SAVE AS DIALOG BOX will pop up so that client can choose output destination folder. This is my CODE [CODE] path = getServletContext().getRealPath("/")+ "files/"; String filename = path + "users.txt"; String disHeader = "Attachment;Filename=\"users.txt\""; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition",disHeader); System.out.println(filename); File fileToDownload = new File(filename); FileInputStream fis = new FileInputStream(fileToDownload); try { //response.reset(); ServletOutputStream fos = …

+0 forum 0

The End.