Guys, I have a web app that has view from JSPs. I need to create a JSP page to force the download of different types of files - doc, xls, pdf etc and not open it by default in the browser (IE/Firefox). The other problem is the file path is not on my webserver document directory but on a UNC drive (universal naming convention) eg. \\server\folder\file.xls
Please give me suggestions how I can download this using jsp.
Hmm context.getResourceAsStream is probably not the best way to get a file that's outside of the scope of the app. The example was for reading files/resources from within the app or war file. Using FileInputStream was a good idea.
Why are you creating a printwriter variable? Are you still using response.getOuputStream to stream the file down to the browser?
How big are the files? [ February 11, 2005: Message edited by: Ben Souther ]
Joined: May 26, 2004
I was using the PrintWriter and looks like that was the cause of the performance issue. I replaced it with
and it has better performance. Do you have any other alternatives better than getOutPutStream ? My files are in the range if 1 to 10 MB ~ML [ February 11, 2005: Message edited by: Martin Lira ]