• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP to list files in a folder  RSS feed

Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I was just wondering if anyone could help me.

Im trying to create a JSP which will display all the images in a folder.

Now the folder path is stored in a databse entry. This folder will contain a number of image files (TIFF mainly) and a few PDF files. I need the page to look through the folder and display all of the images to page.

So if the database entry is "D:\DATA\images\" the page displays all images under that path. I was thinking along the lines of this:

ResultSet rs = stmt.executeQuery(strGetDataSQL);
while (rs.next()) {
strFolder = rs.getString("folder");
strPath = rs.getString("path");
strImageLocation = strPath+strJobFolder;

<img src="<%=strImageLocation%>" alt="" />


This finds the folder, but I still need a way of putting the names of each image file on the end of "strImageLocation".

I can't put each individual filename into the database either as there will be literally 100s (even 1000s) of them, that is why I'm looking for a JSP that will browser through the contents of the folder itself.


Ranch Hand
Posts: 39
Posts: 13411
Firefox Browser Redhat VI Editor
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!