• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
btw this needed to add images from a security IP camera and view in a web page all images currently....
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic