• 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

How to specify output path for an image file?

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have an application deployed on tomcat. The application is supposed to generate an Image file (myImage.png).

I want to display this image on a JSP page. When i run the application the image file is not generated in any of tomcat folder hierarchy.

The way i have specified the output path for the image is



How do i specify path so that this image is output in my tomcat/webapps/app folder?

Thank you in advance.
Regards,
Gaurav
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the image is not under your webapp's directory structure, you'll need to write a servlet that streams the image to the browser.

This is not difficult.
I have an example app that does this.
http://simple.souther.us
Look for SimpleStream.

In that app, I'm using getResourceAsStream to read image files under the webapp's directory structure but hidden from the web under WEB-INF.

In your case, you will have to use java.io.FileReader to read your image files but, otherwise, everything should be the same.
 
Do not threaten THIS beaver! Not even with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic