0

I am using apache tomcat and i have some files in my system, I am creating links of these files with the below JSP code.

<%
File files = new File("/Users/user1/tests");
File[] fileList = files.listFiles();
for(int i=0; i<fileList.length;i++) {
    File f = fileList[i];
    out.println(i+". <a href='"+f.getAbsolutePath()+"' >"+f.getName()+"</a>");
}
%>

Now the links are generated fine, but when i click on these links apache is throwing 404 error. How can i make apache to access that folder.

Sumit Kumar
  • 402
  • 1
  • 6
  • 26

1 Answers1

-1

On local system if your file is in another directory except to current web directory You need to set full absolute path of file to download a file using href.

Syntax is:-

out.println(i+". <a href='file:///"+f.getAbsolutePath()+"' >"+f.getName()+"</a>");
Altmish-E-Azam
  • 1,561
  • 1
  • 13
  • 24