• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Getting directory location in JSP

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am able to do it using getRealPath()

Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic