This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic