Hello everyone,
I would like to develop an application which chooses a folder and display the name of all files in that folder.
How can I achieve this?
The jsp or html page should let me to select the folder and I should have a servlet to do the next action.
Can anyone please give me an idea about this? Is there any API?
Choosing a Folder instead of a file
Page 1 of 13 Replies - 2535 Views - Last Post: 12 March 2012 - 01:54 AM
Replies To: Choosing a Folder instead of a file
#2
Re: Choosing a Folder instead of a file
Posted 20 January 2012 - 04:44 PM
Utilize the Java's File API. In your Servlet, get a list of the files you want to present to your user and render them into the HTML. Make them links with POST parameters, so you can get the directory that the user wants to explore next. I went ahead and made a DirectoryServlet to give you some idea of how it could be done. This servlet is only for files in your web root, although it could easily be adapted to display files outside it. File downloads outside your web root must be initiated from inside servlet code, which is more work, but your files won't be publicly accessible. DirectoryServlet is something you might find as a part of the web interface to a public code repository.
I saw your other post with a Javascript snippet. If your going to use an AJAX-based solution, you don't have to change the servlet. All you need to do is extract the anchor tags from the response html, which I'm sure a parser exists for. For each anchor tag, extract the inner html, display that in your combo box. Save the value of href in a map, which you'll use in your next asynchronous call.
I saw your other post with a Javascript snippet. If your going to use an AJAX-based solution, you don't have to change the servlet. All you need to do is extract the anchor tags from the response html, which I'm sure a parser exists for. For each anchor tag, extract the inner html, display that in your combo box. Save the value of href in a map, which you'll use in your next asynchronous call.
This post has been edited by blackcompe: 20 January 2012 - 04:54 PM
#3
Re: Choosing a Folder instead of a file
Posted 11 March 2012 - 10:42 PM
I apologize for the delay in reponding back as I was busy with some other project.
Thanks Ryan, your Directory Servlet helped me out. It sorted both of my issues.. Thank you so much
Thanks Ryan, your Directory Servlet helped me out. It sorted both of my issues.. Thank you so much
#4
Re: Choosing a Folder instead of a file
Posted 12 March 2012 - 01:54 AM
Awesome. Glad it got some use.
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote



|