Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8039779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:41:05+00:00 2026-06-05T03:41:05+00:00

i want to display directory and its files in link format that is if

  • 0

i want to display directory and its files in link format that is if i click the directory it should display the files in that directory.i tried to get the directory as a link but dont know how to get the files

my code for getting directory as a link.

<%
try{
File dirName = new File("/home/adapco/Desktop/Startest/");

if (dirName.exists()&& dirName.isDirectory())
{
//out.print("path: " + dirName.getAbsolutePath() + "<br>");
String[] allFiles = dirName.list();
for (int i=0; i < allFiles.length; i++)
{
out.println(allFiles[i] + "<br>");
%>
<a href="Startest/<%=allFiles[i]%>"><%=allFiles[i]%></a>
}
}
}
catch (IOException ex){
out.println("Exception Occured");
}
%>

i tried to get the file in the same manner but it isnt working

File folder = new File("/home/adapco/Desktop/Startest/");
File[] listOfFiles = folder.listFiles();

i want to know how to get both directory and files and link them up in order to browse.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:41:07+00:00Added an answer on June 5, 2026 at 3:41 am

    Result of folder.listFiles() is array of files and directories. It is all there. You can use file.isDirectory() or file.isFile() to detect is it directory or file.

    You will have servlet/controller that is mapped to “/filesystem/*”, that you can extract path that is after filesystem/folder1/folder2 -> folder1/folder2. Add to this path you filesystem, create file and return content of folder. So link to folder2 will be:

    <a href="<c:url value='/filesystem/folder1/folder2'/>">folder2</a>
    

    To encode not supported in url symbols use URLEncoder() for folders names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a directory that will be getting updated frequently, I want to display
I want to be able to create a tree view that can get its
ls displays the files available in a directory. I want the file names to
In the header of the django admin, I want display a link. This link
I am using the Gallery3D -Code but want it to only display images from
My App has a database file in its NSBundle. I want to get update
I want display data from database in Listbox...Here is my code, It is not
i want display 1 record from colums zodys , I'm programint in C# I
I have a simple quiz application and I want display a nice timer /
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.