I'm developing an application designed to return records along with any associated images. The images will be named after the records primary key; ie "102.jpg". I'm going to display the full record information on one jsp and provide a link to another jsp to display the image, via a button/link whatever.
The problem is that not all records have associated images. I have to engineer the system such that the link appears ONLY when an image is present in the img directory. How can I test at runtime whether file 102.jpg is present?
Right . . . I've found plenty of reference to a FindFile class/object/something but it doesn't appear to be available to my application as it stands. How do I get access to this?
I think from the primary key you can get the file name. Then when you use the following code, File f = new File("File name"); if(f.exists()) { //your file exists } else { //file doesn't exist. }
I guess you missed it on your way in, buy your display name doesn't quite meet up with our Naming Policy. In short, you must have a real (sounding) first name, a space, and a last name.
Never ascribe to malice that which can be adequately explained by stupidity.
Dave Mere
Ranch Hand
Joined: Oct 25, 2004
Posts: 37
posted
0
Jesper, Shobhana, thanks for your informative replies - it's all working now!
Jeff - whereas this solution is obviously clear to one as Sun-certified as yourself, sometimes they are less so to those of us with less experience. Half a reply isn't much use when you're on a deadline.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Dave,
I was trying to follow the Java Ranch credo of "Give a man a fish... Teach a man to fish..."
Half a reply isn't much use when you're on a deadline.
Following Dave's advice would have been a * of alot faster than waiting for a reply. Get familiar with the basic Java library if you are using java.io classes it should be obvious that they use the java.io.File class to represent the disk file. Bill