<%@page import="java.sql.Statement"%>
<%@page import="org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload" %>
<%@page import="org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory" %>
<%@page import="java.io.*,java.util.*, javax.servlet.*" %>
<%@page import="javax.servlet.http.*" %>
<%@page import="org.apache.tomcat.util.http.fileupload.*" %>
<%@page import="org.apache.tomcat.util.http.fileupload.disk.*" %>
<%@page import="org.apache.tomcat.util.http.fileupload.servlet.*" %>
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
 
[QUOTE]


    
        Image Retrieval System
        
    
    
        <%@include file="path_handler.jsp" %>
 
        
Image Retrieval System

Manage operation results

<% if (request.getParameter("upload") != null) { String sUploadFName = ""; int r = 0; File file; // Verify the content type String contentType = request.getContentType(); if ((contentType.indexOf("multipart/form-data") >= 0)) { DiskFileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); try { // Parse the request to get file items. List fileItems = upload.parseRequest(request); if (fileItems.size() == 1) { FileItem fi = (FileItem) fileItems.get(0); if (!fi.isFormField()) { // Get the uploaded file parameters sUploadFName = fi.getName(); // Write the file String sUploadPath = sImagesDir + sUploadFName; // out.println(sNewFilePath); file = new File(sUploadPath); fi.write(file); // insert image properties at database r = mdbm.AddImage(sImagesDir, sUploadFName); } } } catch (Exception ex) { // out.println("Error adding image
" + ex); } } else { // out.println("No file uploaded"); } if (r == 0) { %>

Successfully uploaded image "<%= sUploadFName %>" at path "<%= sImagesDir %>".

Successfully added image "<%= (sImagesDir + sUploadFName) %>" at database.

<% } else { %>

Error adding image (<%= r %>).

<% } } %> <% if (request.getParameter("create_db") != null) { // build database int r = mdbm.CreateTASdb(); if (r == 0) { %>

Database has been created successfully.

<% } else { %>

Error creating database (<%= r %>).

<% } } %> <% if (request.getParameter("add_all_images") != null) { // build database int r = mdbm.AddAllImages(sImagesDir); if (r == 0) { %>

All images added to database successfully.

<% } else { %>

Error adding images to database (<%= r %>).

<% } } %> <% if (request.getParameter("clear_db") != null) { // drop database int r = mdbm.DropTasDB(); if (r == 0) { %>

Database cleared successfully.

<% } else { %>

Error clearing database (<%= r %>).

<% } } %>

Return to manage page.