• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting directory location in JSP

 
Ambika Jain
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my jsp code, I need to get the directories under the directory "files"
and then display in the the jsp page. I have my code below.
I dont want to hardcode the path "C:/Tomcat5/webapps/insurance/files",
How can I do it ?

-------------------------code---------------------------
String filedir="";
File file = new File("C:/Tomcat5/webapps/insurance/files");

File fileDirs[] = file.listFiles();

String s ="";

for(int i=0; i< fileDirs.length ;i++){
s = s + "<P> <a href=files/" + fileDirs[i].getName() + "> "+ fileDirs[i].getName() +" </a> ";

--------------------------------------------------------------

Thanks.
 
Ambika Jain
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to do it using getRealPath()

Thanks.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!