Results 1 to 6 of 6

Thread: To view the list of directories using HTML

  1. #1
    Join Date
    Feb 2017
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default To view the list of directories using HTML

    Hi,

    I want to list the directories available on some location(say some path) on linux box using HTML. Can someone please help writing the index.html.
    So I can access over the web.

    Tried using .htaccess, and could not get any results. is something do we need to enable from apache server. please let us know earliest. Thanks!!!

    Thanks,
    Sowmya

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Actually it's the absence of an index page that lets you see the directory listing. And yes, it has to be allowed in the server configuration, though that should be able to be modified for any given folder or folders using .htaccess. Most servers allow it by default though.

    If you have a page named home.*, index.*, or default.* (the * being like html, htm, php, asp, or some other valid presentational extension) in the folder, by default the browser will see that. If not, it should see the directory listing.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2017
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes. Thanks John. By default browser is referring the index.html and listing the directories. I have coded manually in index.html to show the directories. Someone help writing the HTML code which automatically lists the directories available in the respective location.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    HTML isn't that powerful. As I say, as long as there's no index or other default page in the folder, simply navigating to the folder will list the entries. Like if you have a folder called demos on whateverdomain.com that has no default page in it and you go in your browser to:

    http://www.whateverdomain.com/demos

    most servers will show the directory listing. Now, whether the server is configured to do that or not, no HTML page can show the directory, at least not by itself. If the server has PHP, a .php page could. And an HTML page that fetches (via javascript and AJAX) the contents of a PHP script could. Even an HTML page could do it directly via PHP if the server parses it as PHP (must be set in the server's configuration or via .htaccess). This can also be done in asp or ASP.NET and other server side languages. But using only HTML, it cannot be done.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2017
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you John.

    It worked by following as below,

    Let's make a simple application for an online document share, which lets us browse it's /files folder.

    First create a new application folder in your webapps folder called Browser

    In the new Browser folder, create two folders: WEB-INF and files

    The files folder will be our browseable folder. Create some other subfolders under files (eg: photos and code), and add a few example files such as some photos or source code, so that we have something to browse.

    Copy the following into /Browser/WEB-INF/web.xml:

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    
    <web-app>
    
        <display-name>Browser</display-name>
        <description>File Browsing Application for the Document Share</description>
    
        <!-- Enable directory listings by overriding the server default web.xml -->
        <!-- definition for the default servlet -->
        <servlet>
            <servlet-name>DefaultServletOverride</servlet-name>
            <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
            <init-param>
                <param-name>listings</param-name>
                <param-value>true</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <!-- Add a mapping for our new default servlet -->
        <servlet-mapping>
            <servlet-name>DefaultServletOverride</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    
    </web-app>

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Definitely not HTML. Glad you figured this out. Does that all go on the server? When you view that in a browser*, does the address in the address bar end in .htm or .html? or is it just files or files/ at the end of the address?

    This was for viewing in the browser, right?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Replies: 2
    Last Post: 03-13-2012, 08:02 AM
  2. Scrip To View Images With Numbered List
    By Markxxx in forum Looking for such a script or service
    Replies: 1
    Last Post: 07-11-2010, 05:33 PM
  3. Splitting HTML View
    By Freddie in forum HTML
    Replies: 2
    Last Post: 07-07-2010, 07:24 PM
  4. Replies: 0
    Last Post: 02-01-2010, 10:55 AM
  5. Opening files in list view
    By Fatal Exception in forum HTML
    Replies: 1
    Last Post: 02-01-2006, 06:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •