<%
   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" />
<%
   }
%>
<%@ page language="java" import="java.util.*, oracle.jsp.webutil.fileaccess.*, oracle.jsp.dbutil.*, java.sql.*" errorPage="error.jsp" contentType="text/html;charset=UTF-8"%>
<html>
<body>
<jsp:useBean id="cbean" class="oracle.jsp.dbutil.ConnBean" >
<jsp:setProperty name="cbean" property="dataSource" value="<%= connStr %>"/>
</jsp:useBean>
<%! Connection conn = null; %>
<% try {
     cbean.connect();
     conn = cbean.getConnection();
   } catch (Exception ae) {
     out.println("<P>" + "There was an error connecting:");
     out.println ("<PRE>" + ae + "</PRE> \n <P>");
 }
%>

<jsp:useBean id="upbean" 
   class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
<jsp:setProperty name="upbean" property="connection"  
   value="<%= conn %>" />
<jsp:setProperty name="upbean" property="destination"  
   value="beanexample" />
<jsp:setProperty name="upbean" property="destinationType"  
   value="database" />
<jsp:setProperty name="upbean" property="overwrite" 
   value="true" />
</jsp:useBean>

<% try {
     upbean.upload((HttpServletRequest)request); 
   } catch (FileAccessException ae) {
     out.println("<P>" + "There was an error doing the upload:");
     out.println ("<PRE>" + ae + "</PRE> \n <P>");     
  }
%>
  Uploaded the following files:
<ul>
<%   Enumeration fileNames = upbean.getFileNames();
     if (fileNames != null) {
        while (fileNames.hasMoreElements()) { %>
  <br><li><%= (String)fileNames.nextElement() %></li>
<%   } %>
</ul>
<%} else { %>
<br>Done!
<%} %>
</body>
</html>
