Directory / File listing of website

Hi,I'm trying to get my jsp file to list the contents of a directory on my website but using the method of creating a file and listing it's contents doesn't seem to work.. Can anyone help with this?Thanks,Phil
[240 byte] By [phil_stennetta] at [2007-11-26 22:54:22]
# 1
> doesn't seem to workPlease elaborate.
BalusCa at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi philWhich method u used to list out the directory files...
Chellama at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

If I try to use a relative path (for example just ./) it lists the contents of the directory that the tomcat server is running in rather than the directory of the jsp file and if i use an absolute name http://localhost:8080/ it comes back with nothing in the list.

File dir = new File("./");

String[] children = dir.list();

if (children != null) {

for (int i=0; i<children.length; i++) {

String filename = children;

out.println(filename);

}

}>

phil_stennetta at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Hi phil,Give your relative path and the path of the files name where u have saved your Jsp files....
Chellama at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Running on a local tomcat server i want to view files in any directory from http://localhost:8080/. This is where the jsp file is on the website. On the computer it's in the webapps/ROOT/ directory of the tomcat server.

If I use the relative path ./ it puts me in the base directory of the tomcat server and if I use the absolute path http://localhost:8080/ it returns nothing.

phil_stennetta at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Hi Phil,I used application.getRealPath ( "\\" ) ; which helpled me to list the files from the directory
Chellama at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Brilliant, thank you!BTW it didn't work on my remote server with the \\ but it worked when i took them out (worked fine on local server as it was).
phil_stennetta at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Thats Fine
Chellama at 2007-7-10 12:18:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...