You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Grondell, Ken" <ke...@fairmarket.com> on 2002/05/03 20:23:13 UTC

RE: List file relative to jsp

this works for me on windows

<% 
response.setHeader("Cache-Control","no-store");
String directory = getServletConfig().getServletContext().getRealPath("\\");
File myFile = new File(directory);
String[] dirs = myFile.list();
for(int i=0;i<dirs.length;i++){
out.println(dirs[i]+"<br>");
}
 %>


-----Original Message-----
From: Adam Pfeiffer [mailto:adamcpfeiffer@yahoo.com]
Sent: Friday, May 03, 2002 2:27 PM
To: tomcat-user@jakarta.apache.org
Subject: List file relative to jsp


I am running Tomcat 4.0.  I am trying to list all files and directories in a
directory relative to
a jsp.  Here an example:

My jsp page is at:
/opt/jakarta-tomcat-4.0.3/webapps/examples/jsp/TestPage.jsp

The directory which I want a listing of all files and directories in is at:
/opt/jakarta-tomcat-4.0.3/webapps/examples/jsp/trips/images

lets say there are 3 images with the names of image1.jpg, image2.jpg,
image3.jpg. 

I want a method that would return 
trips/images/image1.jpg
trips/images/image2.jpg
/trip/images/image3.jsp

when called from TestPage.jsp

Thanks for you help in advance.

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>