title: How to interact with list of contents of a server directory using JSP?
body: <p>I have a simple code like this:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Directories Example&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Directories&lt;/h1&gt;
  &lt;ul&gt;
  &lt;%
  String root="c:/";
  java.io.File file;
  java.io.File dir = new java.io.File(root);
  
  String[] list = dir.list();
  
  if (list.length &gt; 0) {
  
  for (int i = 0; i &lt; list.length; i++) {
    file = new java.io.File(root + list[i]);
    if (file.isDirectory()) {
    %&gt;
    &lt;li&gt;&lt;a href="/&lt;%=list[i]%&gt;" target="_top"&gt;&lt;%=list[i]%&gt;&lt;/a&gt;&lt;br&gt;
    &lt;%
       }
    if (file.isFile()) {
        %&gt;
        &lt;li&gt;&lt;a href="/&lt;%=list[i]%&gt;" target="_top"&gt;&lt;%=list[i]%&gt;&lt;/a&gt;&lt;br&gt;
        &lt;%
      }
    }
  }
  %&gt;
  &lt;/ul&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Output:
  <a href="https://i.stack.imgur.com/3MBMA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3MBMA.png" alt="Output of code"></a>
  How I can interact with folder or file by clicking on its link? I mean - open folder or make some action with file? What I need to change? I understand that it has to handle clicking on links but do not understand how to do it. What I need to google?</p>