I'm trying to get a directory list using a
JSP. The directory (called 'xml')is directly beneath the webapps directory (in
Tomcat 5). For some reason the code works when not in a JSP. Put it into a JSP and it doesn't. Here's the code:
<%
java.util.ArrayList lessons = new java.util.ArrayList();
try {
java.io.File file = new java.io.File("xml");
String [] files = file.listFiles();
for(int i=0; i<files.length; i++) {
out.println(files[i] + "<br>");
if(files[i].startsWith("jav") && files[i].endsWith(".xml")) {
lessons.add("xml/" + files[i]);
}
}
} catch(Exception ignore) {
out.println("Error: " + ignore);
}
request.setAttribute("lessons", lessons);
%>
The list() method doesn't seem to return anything (resulting in a NullPointerException when I try and access it). Any clues?
Ta!