I have a collection of PDF files saved in a local directory on D:/filesDir/. I am looking to showcase all the files from that folder on my JSP page. When a user clicks on a specific PDF file, it should directly open the corresponding file located in D:/filesDir/. Currently, this is how my code looks:
<%
String sourceDirectory = "D:\\filesDir\\";
File f = new File(sourceDirectory);
String [] fileNames = f.list();
File [] fileObjects= f.listFiles();
%>
<UL>
<%
for (int i = 0; i < fileObjects.length; i++) {
if(!fileObjects[i].isDirectory()){
%>
<LI>
<A HREF="<%="D:/filesDir/"+fileNames[i] %>"><%= fileNames[i]%></A>
(<%= Long.toString(fileObjects[i].length()) %> bytes long)
<%
}
}
%>
</UL>
Although I can display all my PDF files from the filesDir folder on my JSP page with the above code, when a user clicks on a specific PDF file like abc.pdf, instead of opening D:/filesDir/abc.pdf, it redirects to localhost:8080/myapp/D:/filesDir/abc.pdf...
Is there a way to remove the application-specific path (localhost:8080/myapp/) and open the PDF file directly from the link?