How do I populate a dropdown list (in a JSP page) dynamically with all the folders present in the same directory as the JSP page, on Apache Tomcat?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
use
servletContext.getRealPath("/someuidir-in-your-webapp/somejspdir")to get the absolute path of the directory of that jsp and then use the java.io.File and java.io.FileFilter (filtering directories) . Here’s the javadoc for getRealPathAdding some code (You can put this in your jsp). Note that this is just an example to get you started on how to do it. It may need some imporovement (in terms of design)