aspose file tools*
The moose likes JSP and the fly likes Accessing images from another path in UNIX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Accessing images from another path in UNIX" Watch "Accessing images from another path in UNIX" New topic
Author

Accessing images from another path in UNIX

Raghu Nathan
Ranch Hand

Joined: Jan 16, 2006
Posts: 44
Hello people,
I have a problem that I have been trying to address and have been unsuccessful.
I have an application where the user is shown a series of JSPs and upon entering data in those there is a final content generated which is converted to PDF.
Now, during in these contents also have images, the path of which is prescribed in a DB table. So at run time, I would know which path to look up and what file to pick up and generate in this dynamic HTML.
These images are not in the same path as the regular images that we have as part of the application; meaning application specific images in ../images folder where the the JSPs are housed.
Now when these dynamic pages are shown, the image does not come up at all however when the final PDF is created, we are able to see the images perfectly.
If the path where the PDF is generated is say /folder1/folder2/pdf; then the images are fetched from /folder1/folder3/image/ - so its somehow able to recognize the image path and show it in the PDF.
What changes must I do in my dynamic pages so that the images are shown duiring the dynamic pages generation as well as in the final pdf.
I do not know if I have been very articulate in describing my problem, but pl do reply if you have had this problem in the past or know how to solve this.
Thanks in advance


Thanks ... Raghu
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Is the directory that houses the images inside your webapp?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Raghu Nathan
Ranch Hand

Joined: Jan 16, 2006
Posts: 44
I do not know which images folder you are asking; there is the one images folder that is within the path where we have all the JSPs and then there is this other images folder.
Regardless, both folders, are part of the Web Server and App Server.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

List the path to the two image folders.

You can only link directly to images that are
A) within your webapp and
B) not under the WEB-INF directory.

If your image directory doesn't meet this criteria, you will need to build a servlet that streams the image files to the browser.
Raghu Nathan
Ranch Hand

Joined: Jan 16, 2006
Posts: 44
Thanks for your reply.

These are not in the WEB-INF folder. But they secondary images path has been given by the users.
This is a Unix box.
I was reading somewhere that if we have a virtual fodler; it might do the trick. I have never used Virtual folders and am curious to know if this would indeed solve the issue.

I need some help big time in this ...

Thanks again.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Raghu Saranathan:

I need some help big time in this ...


How can anyone help you if you keep ignoring the questions being asked?
What is the path to the images that you want to show from your JSPs?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Raghu Saranathan:
But they secondary images path has been given by the users.
This is a Unix box.

What does this mean?



Originally posted by Raghu Saranathan:
This is a Unix box.

Doesn't matter
Raghu Nathan
Ranch Hand

Joined: Jan 16, 2006
Posts: 44
Ok the path that I want to show from my JSPs are in another folder;

I will tell you the exact path if you need:

#1
Here is where we have the JSPs;
/export/home/oti/oc4j/j2ee/home/applications/teachext/teachext/

#2
The images that we show in the application for buttons and logos are withing a folder called images within the above path:
/export/home/oti/oc4j/j2ee/home/applications/teachext/teachext/images/

#3
Now, there are a second set of images which are in :
/export/home/oti/oc4j/j2ee/home/teachfiles/letterTemplates/images/

#4
The pdfs get generated in :
/export/home/oti/oc4j/j2ee/home/teachfiles/pdf/

The functionality is such that the user can view the contents of letters (that's what happens in this process) online and when they hit Submit; the html content is converted to pdf.

The pdf being in the different path is able to recognize it after the generation and the images stored in #3 show up in the PDF. Its when the JSPs access the path defined in #3 that I am having a problem.

I am sorry again for not being able to express it properly earlier.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

First, thank you for fixing your name.

OK, it looks like they are outside of your webapp.
In order to link to these images with an HTML img tag from a browser, you will need to either write a servlet that streams images or create a symlink to the images directory from somewhere within your webapp's directory structure.

The streaming servlet would be my first choice.
By default, in Tomcat, symlinks are not followed.
This is for security reasons and I assume most other containers take the same approach.
They are also not portable. Someday, you may have the misfortune of having to deploy this app on something other than a Unix box.

Depending on your server and network, there may be other options as well.
Raghu Nathan
Ranch Hand

Joined: Jan 16, 2006
Posts: 44
Thanks for the reply. However, I do think these run within the Web Server.
I will try to do that and let you know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing images from another path in UNIX