Can an ImageComponent object reference an image in other server locations?
Hello all -
I need display images stored in a folder on the server other than the folder where the web application is stored. However, pointing to any of those jpg images renders nothing as the application runs! To be able to render them, I must copy the images to the web directory of the application and reference them therein, just like in http://www.netbeans.org/kb/55/vwp-fileupload.html. So, this piece of code would work nicely:
String file ="/resources/1.jpg";
image1.setUrl(file);
where of coursefileis a relative path inside the web app, andimage1of typeImageComponentis dropped straight from the pallette. But this would not:
String file ="c:/researcherData/images/1.jpg";
image1.setUrl(file);
Is there a way to enable an imageComponent object to reference non-web-app files? Thank you.
# 2
> Take a look at
> http://developers.sun.com/jscreator/learning/tutorials
> /2/file_upload.html#07.
Thanks jetsons. That particular code sample (#7 in SJSC, #8 in Netbeans) shows only how to serialize a file to a different location on the server, not how to reference a file (not stored within the app forlder) to be rendered as a result of hyperlink click for example. Reading a little further in that page, it says:
Be careful when putting the uploaded files in the web application as anyone can access the files by URL, such as http://localhost:29080/MyWebApplication/faces/upload/images/myPicture.gif.
So, I am thinking that for added security, may be it is meant to be that I can't make an imageComponent reference a file outside of the wep app folder, but I am just guessing. In which case, I will simply have to store all such files within the web app folder before attempting to access them, unless someone has a better answer.
# 3
Sorry about that. The answer might lie with your server docs. For example, go to http://java.sun.com/developer/community/askxprt/2006/jl0424.html and scroll about half way down, where they talk about virtual directories. If you find the solution, maybe you can post here.