File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes BEA/Weblogic and the fly likes Download a file created on runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Download a file created on runtime" Watch "Download a file created on runtime" New topic
Author

Download a file created on runtime

Ricardo Marques
Greenhorn

Joined: May 08, 2002
Posts: 27
Hi.
I have an application which I deploy as a WAR file (JUCK.WAR). In the flow of execution, there comes a time when my application needs to create a file and write data to it so that the user can download the file at will.
I am creating the file in applications/CE/Files/Download, applications being the default "applications" directory in WebLogic 6.1.
When the user wants to download the file, I verify that it exists, and if true redirect to a JSP where there is a link to that file.
I am writing the link as /CE/Files/Download/DesiredFile but when I try to download it, I get a 400 - Not Found Error, saying that it could not find anything matching the request, even though I know for sure that the file exists and that the link is well writen.
I have also tried to use servletContext.getRealPath("/CE/Files/Download/DesiredFile") , but I found out that it only works for files in the WAR file, not files in external directories.
How can I write the URL so that the file can be, in fact, downloaded? I am positive that this can be done...
Thanks everybody.


Sun Certified Programmer for the Java 2 Platform 1.4<p>If I can create, I will make mistakes. If I can learn with them, it must be some kind of art.
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1851
Ricardo,
I think that you should create the folder that you desire in the WebApplication and not in the Ear root.
Example let us say I have a Web Application folder structure like this
\rah.jsp
\download\xxx
\download\yyy
\WEB-INF
I think it is possible to download the file \download\xxx but anything above the "\" context above and anything inside the WEB-INF folder is not downloadable.
Ricardo Marques
Greenhorn

Joined: May 08, 2002
Posts: 27
Ok, I understand that.
But, if my application is closed inside the WAR, how am I ever going to be able to download a file that I generate on runtime? Is there a safe place where I can put it, from where it can be downloaded?
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1851
But, if my application is closed inside the WAR

Actually its just the opposite
The WAR is closed inside a application.
You just have to save the new files in the web application root or folders below it. This is to my understanding.
These files however are accessible to all.
Ricardo Marques
Greenhorn

Joined: May 08, 2002
Posts: 27
OK. I must be missing something ...
If I create the war and all my application files are stored in the war file, the links in my application map to files inside that war, since I have no directory structure.
How, then, do I create and write a file to be downloaded if I have no directories, just a single WAR file? It seems quite hard for me to write the file to a directory that only exists (at best) in the WAR file... where I cannot (IMHO) add files since the WAR was deployed...
The WebApplication root dir of my application is the WAR file! How can I write a file to a directory inside that?
Thanks again.
 
wood burning stoves
 
subject: Download a file created on runtime