• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JSP to list files in a folder

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out this taglib:
http://www.servletsuite.com/servlets/dirtag.htm
or
http://www.servletsuite.com/servlets/albumtag.htm
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The java.io.File class have everything you will need for this.

http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html
reply
    Bookmark Topic Watch Topic
  • New Topic