This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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.
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.
Joined: Jan 16, 2006
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.
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.
Joined: Jan 16, 2006
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.
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.
Joined: Jan 16, 2006
Thanks for the reply. However, I do think these run within the Web Server. I will try to do that and let you know.