Where do I place a .csv file for the user to be able to download? I know I can create a servlet and change the MIME-TYPE of the output etc, but can't you just stick a file (filename.csv) in the directory /webapp-name/downloads/filename.csv and have the user go to the the URL for it?
For some reason it is giving me an error. Not a container error, but what looks like a browser error.
Maybe I didn't word that question very well. Is there a way to put an excel file on the server and allow the user to download it directly? Without creating a servlet which will read the file byte by byte, change the content-type of the response and set the bytes of the excel file into the response?
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."
And there is a window in the background that is titled "File Download" but it is covered by the first window.
Friendly messages are turned off already, and when I turn them back on it doesn't really tell me anything much better. It first opens a warning window that I am about to download a file (test.csv) and asks if I want to open or save the file. When I click open or save it gives me the same error that it was giving when I had friendly messages turned off.
So basically what I am gathering is that with Tomcat you can't put a file in a directory and allow the user to download it directly. I find this behaviour strange since this is a pretty basic feature of IIS and you'd think it would be a pretty basic feature of Tomcat as well.
I've tried setting mime-types in web.xml and that doesn't work either. I also can't seem to access a microsoft word or powerpoint file that is on the server and both of their mime-types have entries in web.xml as well.
The wierd thing is that another guy on my team can access it just fine. It scares me to think that this is "just a problem with my browser" because more often than not there is more to it than that.
If nobody else can think of any solutions, I am going to try creating a servlet which will read the file byte by byte and write it to a byteArrayOutputStream and then set that into the response. This seems like horrible overkill though.
I thinking browser issue. You could try installing firefox as a test. you could also try downloading something thats not associated a Microsoft product. Finally, use regedit to search for csv and see if you see anything funky.
I have had mime-type issue with Explorer in the past that didn't go away until I rebuilt the OS... but I'm not a windows guru.
We have tried several users browsers and everyone has the same problem. The strange thing is that if I request a file http://someurl.com/filename.csv and I am NOT logged in, I will first get prompted to enter password and then I am redirected to the requested URL where I can download the file (in other words it works). BUT...if I log into the site, then paste the URL directly into that browser session to which I am logged in it will not download the file and gives me the errors suggested above.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop