aspose file tools*
The moose likes JSF and the fly likes How get all image names of files in an image folder in JSF or JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How get all image names of files in an image folder in JSF or JSP" Watch "How get all image names of files in an image folder in JSF or JSP" New topic
Author

How get all image names of files in an image folder in JSF or JSP

Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
How get all image names of files in an image folder in JSF or JSP? after will use SERVER SIDE to eject html to view all images of the folder in a web page...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

J2EE is not a file server architecture. The only way to get the names of image resources is if the web application was designed with an application function to look into whatever places your images are being held and enumerate what it finds there.

This task is further complicated because the official format for a webapp is a WAR file, and unless the server is working with an "exploded" (unzipped) copy of that WAR, there are no actual files, just indexed members of the WAR (ZIP entries). Or, in other words, there's nothing to run the java.io.File list method against.


Customer surveys are for companies who didn't pay proper attention to begin with.
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
btw this needed to add images from a security IP camera and view in a web page all images currently....
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

You can use the java.io.File class and its "list" method to scan a folder and return a list of files that match a filter that you define.

IMPORTANT

Do NOT store image files (or any other uploaded file) inside a WAR. It won't always work and when it does, sooner or later it will bite you. Use an external folder that's not part of either the webapp or the webapp server.
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
What is easier to get done with JSP or with JSF? I did JSP course in the past but recently read 3 chapters in JSF...
ARE THEY THE SAME DIFFICULTY ABOUT?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

No need to shout.

Getting the filename list is POJO and the same code works for JSF, JSP, even Struts.

Presenting the images on a web page is more platform specific and which platform can make that job easiest is debatable. It's about the same amount of work either way.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How get all image names of files in an image folder in JSF or JSP