A URL that begins with "file://" only works on the local file system. It will not work on a server. This prefix should never be used in a web application. The only reason it worked with WSAD is that your server and browser were both on the same system.
Here are two possible solutions:
1- (Preferred) Don't output to a file at all. Simply retrieve the HttpServletResponse object's OutputStream using its getOutputStream() method and then write to it instead of the FileOutputStream. You would then set the content type using response.setContentType() method. Make sure you return null from the execute() method of your Action class to let struts know that you've handled the response and don't need it to forward to a JSP.
2- Create a temporary file in the web application's context so that it is available to be downloaded. You can find the actual file path of the web context with the following statement:
The only reason it worked with WSAD is that your server and browser were both on the same system.
but , I was able to download the file from remote system as well. that is what to my surprise , how come it worked (and still working ) with WSAD ?
thanks , anyway, for your support.
Joined: Feb 15, 2005
All I can tell you is that a URL of file:///xyz/abc/myfile refers to a file on the same file system as your browser. If you developed the app in WSAD and then ported it to a server, what you're getting when you think you're downloading the file from the server is the file on your local system that you created while you were testing on the local system. If you delete this file from your local file system, it will stop working.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com