<%@ page language="java" import="java.util.*, oracle.jsp.webutil.fileaccess.*, oracle.jsp.dbutil.*" errorPage="error.jsp" contentType="text/html;charset=UTF-8"%>
<%
   String connStr=request.getParameter("DSconnStr");
   if (connStr==null) {
     connStr=(String)session.getValue("DSconnStr");
   } else {
     session.putValue("DSconnStr",connStr);
   }
   if (connStr==null) { %>
<jsp:forward page="setconn.jsp" />
<%
   }
%>
<html>
<body>
<%
   // servletPath is the path to the download servlet
   String s = request.getRequestURI();
   String servletPath = s.substring(0,s.indexOf("jsp/fileaccess")) + "servlet/download/";

%>
<jsp:useBean id="cbean" class="oracle.jsp.dbutil.ConnBean" scope="session">
<jsp:setProperty name="cbean" property="dataSource" value="<%= connStr %>"/>
</jsp:useBean>

<jsp:useBean id="dbean" class="oracle.jsp.webutil.fileaccess.HttpDownloadBean" scope="session">
<jsp:setProperty name="dbean" property="sourceType" value='<%="database" %>' />
<jsp:setProperty name="dbean" property="recurse" value='<%=true%>' />
<jsp:setProperty name="dbean" property="connection" value="<%=cbean %>"/>
<jsp:setProperty name="dbean" property="source" value="bean"/>
</jsp:useBean>

<%    cbean.connect();
      dbean.listFiles(request);
%>

     The following files were found:

     <% Enumeration fileNames = dbean.getFileNames(); 
        while (fileNames.hasMoreElements()) { 
         String name = ((String)fileNames.nextElement()).replace('\\','/');
     %>
    <br><a href="<%= servletPath + name +
    "?"+FileAccessUtil.SRCTYPE_PARAM + "=" + dbean.getSourceType() +
    "&"+FileAccessUtil.TABLE_PARAM + "=" + dbean.getTable()  +
    "&"+FileAccessUtil.PREFIX_COL_PARAM + "=" + dbean.getPrefixColumn() +
    "&"+FileAccessUtil.DATA_COL_PARAM + "=" + dbean.getDataColumn() +
    "&"+FileAccessUtil.FNAME_COL_PARAM + "=" + dbean.getFileNameColumn() +
    "&"+FileAccessUtil.FILETYPE_PARAM + "=" + dbean.getFileType() %> ">
         <%= name %></a>
     <% } %>

<br>Done!
</body>
</html>
