This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes How to specify output path for an image file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to specify output path for an image file?" Watch "How to specify output path for an image file?" New topic

How to specify output path for an image file?

Gaurav Pawar
Ranch Hand

Joined: Sep 12, 2006
Posts: 37
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.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

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.
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 to read your image files but, otherwise, everything should be the same.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
subject: How to specify output path for an image file?
It's not a secret anymore!