• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

File System Files Access by Tomcat

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a very big problem. In my Web Application I have to open some images (.tif) in my Jsp.
The problem is that all those images togheter are very strong (a lot of Gb) and so I have to place them into different subdirectories inside the main directory. The main directory is quite strong, and so I cannot place it under my Application's defaultroot, at the same level than jsp, neither in the .war file. I have to place it in another file system directory than this. So, I need my jsp to be able to enter into this file system directory and also into all of its subdirectories.
How can I do that??
OS: Windows 200 Server
AS: Tomcat 4.0.6
Thanks a lot... and sorry for my English!
bye
 
Sheriff
Posts: 67503
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marco,
While I would argue that this sort of processing would be best done in a servlet, bean or custom tag rather than in code directly on a JSP, I'm not sure exactly what aspect of file I/O you are having difficulty with.
If the files reside outside of your web application (which is what I am guessing based upon your post) and you know where the files are, "normal" file I/O should suit you just fine.
If you want to "feed" your web application the location rather than hard-coding it in the code (always a good idea), you can use init params in the web.xml to let your app know where to look for the files.
If the files are within your web application and you need to locate them relative to the root of the web app, the ServletContext.getRealPath() method is your best friend.
Does any of this help? Or am I completely missing what problem you are having?
hth,
bear
 
Saloon Keeper
Posts: 23279
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My English ain't so good either, so don't feel too bad.
As I read it, you want to display a large (file size) TIFF image in a browser window. If you use a JSP or servlet, you can open a file and simply copy it (MIME type x-image/tif or something like that) from any file location the server can see - whether it's actually been bundled into the webapp (not recommended for this use) or located on some LAN server that the web server maps to. The logic itself is simple. Once you've set the headers, open the source image file and copy it to the output stream. It's a good idea to send a Content-length header with the file size in it (PDF's have been known to display improperly if you don't send a valid Content-Length).
A common practice for even better performance is to front-end the appserver with a pure web server such as Apache and have apache fetch and transmit the documents directly. You can do this if there's no processing required. JSPs and other Java resources are simply passed on from the Apache server to the Java server.
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic