• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Download a file created on runtime

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic