ronenr
asked on
Building a URL for a Servlet generated file
I have a Servlet that creates a CVS file based on some user specifications. The file is created but it is created on my weblogic domain root (user_projects/domain/mydo main)
The issue is that after I created the file I need to provide an URL for the user to download the file, since the deployment is on a WAR file it is not clear for me where should I store the CSV file for been able to provide a URL to the user.
The issue is that after I created the file I need to provide an URL for the user to download the file, since the deployment is on a WAR file it is not clear for me where should I store the CSV file for been able to provide a URL to the user.
ASKER
More or less since I need to return a HTML page with information and that page should include the link to the file or the browser pop-up requesting to save or open the file. With your example may I also return the HTML page with the same stream?
you can return an HTML page with link again to the servlet URL with additional parameter for exmple.
and in the second invocation just do retrive csv and return it like in my example
and in the second invocation just do retrive csv and return it like in my example
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, what I am trying to understand is, Is there a way to store the file on the server and build an URL for it (so the user can click the link and get the file) or I must retrieve the file using a servlet as your example suggest. In the case that the only way is to use a servlet to read and send the file the question was answer but if there is a way I can store the file and provide a link to it more information is needed.
ASKER
Although it do not directly answer the question about where to store the file on a Weblogic server I will use the solution suggested. Thanks for taking the time at looking at this issue.
you can directly stream generated CSV file to the client's browser.
Example code follows.
Open in new window