This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • 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...
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic