• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retrieving a directory listing from JSP

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
simply put is this possible from a specific object (ie Directory or File Object) from within JSP? I realize there are ways of doing it with Runtime object and "ls" / "dir", but I was wondering if there was any "cleaner" way than parsing the returning stream from these processes. Thanks in advance!
-MLA
 
Author
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would have thought you could do this from JSP exactly the same way as you can from a Java App. Create a new java.io.File object (new File (path)), call the listFiles method and use the returned array of files to print out the names (through the use of File.getPath() or such like.
Not sure on the directories that you will be able to see. Give it a go and see.
S
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can definately do this is jsp, the way Sam has described. I have done it.
Trevor
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, you can do this, but the directories that you will see will be from the server that the JSP is running. You wont be able to see the client's directory structure since the JSP is compiled and executed on the server, so dont waste your time if this is your intention.
SAF
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic