• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP to list files in a folder

 
Bob Backlund
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;
%>

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

<%
}
%>

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.

Cheers

K.S.
 
Dan Novik
Ranch Hand
Posts: 39
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!