Heres my code to download file:
response.setContentType("text/plain"); response.setContentType("text/plain"); response.setHeader("Content-Disposition", "attachment;filename=C:testing.docx"); ServletContext ctx = getServletContext(); InputStream is = ctx.getResourceAsStream("/test.docx"); int read=0; byte[] bytes = new byte[4200]; OutputStream os = response.getOutputStream(); while((read = is.read(bytes))!= -1){ os.write(bytes, 0, read); } os.flush(); os.close(); I was wondering if there's a way to download the file to a specific location on your desktop using the servlet code. So if I want it to download to the Document folder.
isfor null before using it.