File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving a directory listing from JSP

 
Michael Arnett
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Sam Dalton
Author
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Trevor Dunn
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can definately do this is jsp, the way Sam has described. I have done it.
Trevor
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic