I have a web system in which I have a folder with files and what I am trying to do is bring the names of the files into that folder.
I command to call a JSP from JS
:
getUrlJsonObject({
href:pathcamp+'getNamesDocs.jsp',
method:"GET",
},
function(data){}
This is theJSP
<%
final File folder = new File("/docs");
for (final File fileEntry : folder.listFiles()) {
if (fileEntry.isDirectory()) {
listFilesForFolder(fileEntry);
} else {
System.out.println(fileEntry.getName());
}
}
listFilesForFolder(folder);
%>
But it throws me the following error:
An error occurred at line: 2 in the jsp file: getNamesDocs.jsp
File cannot be resolved to a type
1: <%
2: final File folder = new File("/docs");
3: for (final File fileEntry : folder.listFiles()) {
4: if (fileEntry.isDirectory()) {
5:
listFilesForFolder(fileEntry);
Thanks in advance.
If that is the complete content of your JSP file, you would need to import the class that contains the
File
. To import it you must include this line at the beginning of your .jsp file: