I wonder if anyone has come across this problem in Manning's book. In listing 4.8 on p53, the line URL url = context.getResource("files/test"); doesn't work quite well. In fact, you have to add a "/" before "files/test" to make it work. Another problem is that by this way, it will always download the jar file by the name of the servlet itself. If you want to specify the name of the download file, you have to add another line: res.setHeader("content-disposition", "attachment;filename=test.jar"); after line: res.setContentType("application/octet-stream"); Can anyone tell me the difference between: res.setContentType("application/octet-stream"); and res.setContentType("application/jar"); Thanks a lot.
posted 13 years ago
Hi, ServetContext.getResource(String path) The api says that path must start with a slash so it's probably just a type o. Your other question, I can't answer Dominic