• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

store a file in the server

 
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi pals,

i got a servlet is going to connect to a DB then do some queries then write the result in excel file on the local hard disk , what i wanna instead writing the file on the local hard disk i wanna to store it on the tomcat in a specific path so it can be downloaded ,

Any suggestions ?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want to store it on the file system rather than streaming directly to the client?
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because i need to keep it on the server for a while(1 week) , and to be able to be downloaded anytime later with out running my servlet.

Any advice?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are there any security or authentication issues? getting the file and writing to the Tomcat server using the Tomcat server isn't difficult, if you need to restrict who sees what, than this will affect the design.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
Are there any security or authentication issues? getting the file and writing to the Tomcat server using the Tomcat server isn't difficult, if you need to restrict who sees what, than this will affect the design.



No security concerns i'll put a link in the index page to access the archived files. actually i goggled a lot but i cant find anything useful.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Easiest then is to write them into a directory in the application context (but not in the WEB-INF directory) and allow directory browsing.
 
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, I'd recommend against storing the files within the body of the web application. By doing so, you create complications with upgrades and redeployment. I've done setups like this many times and I store the files independently of the web app so that I can upgrade and redeploy the web app without worrying about clobbering the files,

Access to the files is granted through a servlet that reads the files from the file system and streams them to the client upon demand.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so you recommend streaming upon demand? OK good idea but what if the client wanna access the old files? because like i mentioned before the is reporting tool.
Any advice ?
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My suggestion is to stream the file upon demand. If the record you're going to include in the file is likely to change, you could create a temporary table where you can store a copy of that record. Later, you can delete the temporary record instead of a file.
I feel that much secure, and probably space-saving.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think making this function from scratch will take long time , because i already got the function that writes to local hard dish up and running and the project time is to strict , this why i went for modifying the exist method from writing on HDD to write on server...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think about this - how is your client supposed to locate this output?

Do they get a link to the excel file in an HTML page you return to them? If so then that link could point to a servlet that knows how to locate the file and write it to the output stream will the appropriate headers so that the client's browser will recognize it correctly.

Servlets to accomplish this are quite simple, I think that Bear has an example on his web site.

Bill
 
Bear Bibeault
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually the excellent examples are on Ben's site.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i got it, thanks pals for your support...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic