Example usage for org.apache.commons.fileupload.disk DiskFileItemFactory DiskFileItemFactory

List of usage examples for org.apache.commons.fileupload.disk DiskFileItemFactory DiskFileItemFactory

Introduction

In this page you can find the example usage for org.apache.commons.fileupload.disk DiskFileItemFactory DiskFileItemFactory.

Prototype

public DiskFileItemFactory() 

Source Link

Document

Constructs an unconfigured instance of this class.

Usage

From source file:com.eufar.emc.server.UploadFunction.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    System.out.println("UploadFunction - the function started");
    response.setContentType("text/html;charset=UTF-8");
    response.addHeader("Cache-Control", "no-cache,no-store");
    @SuppressWarnings("unused")
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    FileItemFactory factory = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(factory);
    try {//from w  ww  .  java  2  s. co  m
        List<?> items = upload.parseRequest(request);
        Iterator<?> iter = items.iterator();
        while (iter.hasNext()) {
            Object obj = iter.next();
            if (obj == null) {
                continue;
            }
            org.apache.commons.fileupload.FileItem item = (org.apache.commons.fileupload.FileItem) obj;
            if (FilenameUtils.getExtension(item.getName()).matches("(xml|XML)")) {
                if (item.isFormField()) {
                    String name = item.getName();
                    String value = "";
                    if (name.compareTo("textBoxFormElement") == 0) {
                        value = item.getString();
                    } else {
                        value = item.getString();
                    }
                    response.getWriter().write(name + "=" + value + "\n");
                } else {
                    byte[] fileContents = item.get();
                    String message = new String(fileContents);
                    response.setCharacterEncoding("UTF-8");
                    response.setContentType("text/html");
                    response.getWriter().write(message);
                    System.out.println("UploadFunction - file uploaded");
                }
            } else {
                System.out.println("UploadFunction - file rejected: wrong format");
                response.setCharacterEncoding("UTF-8");
                response.setContentType("text/html");
                response.getWriter().write("format");
            }
        }
    } catch (Exception ex) {
        System.out.println("UploadFunction - a problem occured: " + ex);
        response.getWriter().write("ERROR:" + ex.getMessage());
    }
}

From source file:Admin.products.ProductS.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  ww  w.j av  a 2s.  c  o  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {

        String brand = request.getParameter("sel01n");
        String category_1 = request.getParameter("sel02n");
        String category_2 = request.getParameter("sel03n");
        String category_3 = request.getParameter("sel04n");
        String product_name = request.getParameter("txf01n");
        String description = request.getParameter("txa01n");
        String specifications = request.getParameter("spe00n");

        try {

            String Name = null;
            String Price = null;
            String QTY = null;

            FileItemFactory item = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(item);

            List<FileItem> list = upload.parseRequest(request);

            for (FileItem fileItem : list) {

                if (fileItem.isFormField()) { //form field

                    //                        fileItem.getFieldName().equals("sel01n")) {
                    Name = fileItem.getString();

                    if (fileItem.getFieldName().equals("spe01n")) {
                        System.out.println("NAME-----:" + Name);
                    } else if (fileItem.getFieldName().equals("spe02n")) {
                        System.out.println("VALUE-----:" + Name);
                    }

                } else {

                    System.out.println("---------------" + fileItem.getName());

                    //                        String n = new File(fileItem.getName()).getName();
                    System.out.println(request.getServletContext().getRealPath("/04_admin/product/img/") + "\\"
                            + System.currentTimeMillis() + ".jpg");
                    fileItem.write(new File(request.getServletContext().getRealPath("/04_admin/product/img/")
                            + "\\" + System.currentTimeMillis() + ".jpg"));
                }
            }

        } catch (Exception e) {
            throw new ServletException(e);
        }
    }
}

From source file:controller.uploadPaymentServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//  ww w  .jav a 2  s.c o m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        /* TODO output your page here. You may use following sample code. */
        HttpSession session = request.getSession();
        boolean isMultipart;
        String filePath;

        // Get the file location where it would be stored.
        filePath = getServletContext().getInitParameter("file-upload");

        isMultipart = ServletFileUpload.isMultipartContent(request);

        List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
        String uploadFolder = ("D:\\Dropbox\\CharityWeb_Kloy_Ice\\Implemented_Sytem\\Code\\punpun_final\\punpun_\\punpun_demo_final\\web\\assets\\img\\payment");
        out.print(uploadFolder);
        ServletContext context = getServletContext();
        DataSource ds = (DataSource) context.getAttribute("dataSource");
        DonationUtil donationUtil = new DonationUtil(ds);
        donationUtil.connect();
        String id = request.getParameter("id");
        out.print("ID : " + id);
        Donations donation = donationUtil.findDonationtById(Integer.parseInt(id));
        out.print(donation);
        for (FileItem item : multiparts) {
            if (!item.isFormField()) {
                String name = new File(item.getName()).getName();
                System.out.println(uploadFolder + File.separator + donation.getDonationId() + ".jpg");
                item.write(new File(uploadFolder + File.separator + donation.getDonationId() + ".jpg"));
            }
        }
        response.sendRedirect("success-payment.jsp");
    } catch (Exception ex) {
        Logger.getLogger(uploadPaymentServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Ctrl.Upload.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from  w  ww.java 2  s.  co m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter writer = response.getWriter();

    try {

        if (!ServletFileUpload.isMultipartContent(request)) {
            // if not, we stop here

            writer.println("Error: Form must has enctype=multipart/form-data.");
            writer.flush();
            return;
        }
        // configures upload settings
        DiskFileItemFactory factory = new DiskFileItemFactory();
        // sets memory threshold - beyond which files are stored in disk 
        factory.setSizeThreshold(MEMORY_THRESHOLD);
        // sets temporary location to store files
        factory.setRepository(new File(System.getProperty("java.io.tmpdir")));

        ServletFileUpload upload = new ServletFileUpload(factory);

        // sets maximum size of upload file
        upload.setFileSizeMax(MAX_FILE_SIZE);

        // sets maximum size of request (include file + form data)
        upload.setSizeMax(MAX_REQUEST_SIZE);

        // constructs the directory path to store upload file
        // this path is relative to application's directory
        String uploadPath = getServletContext().getRealPath("") + File.separator + UPLOAD_DIRECTORY;

        // creates the directory if it does not exist
        File uploadDir = new File(uploadPath);
        if (!uploadDir.exists()) {
            uploadDir.mkdir();
        }

        List<FileItem> formItems = upload.parseRequest(request);

        if (formItems != null && formItems.size() > 0) {

            // iterates over form's fields
            for (FileItem item : formItems) {
                // processes only fields that are not form fields
                if (!item.isFormField()) {
                    String fileName = new File(item.getName()).getName();
                    String filePath = uploadPath + File.separator + fileName;

                    File storeFile = new File(filePath);
                    // saves the file on disk
                    item.write(storeFile);

                    request.setAttribute("ten", fileName);
                    request.setAttribute("msg", UPLOAD_DIRECTORY + "/" + fileName);
                    request.setAttribute("message",
                            "Upload has been done successfully >>" + UPLOAD_DIRECTORY + "/" + fileName);
                }
            }
        }

    } catch (Exception ex) {
        request.setAttribute("message", "There was an error: " + ex.getMessage());
    }
    // redirects client to message page
    getServletContext().getRequestDispatcher("/Product.jsp").forward(request, response);

}

From source file:Model.Picture.java

public static ArrayList<String> upload(HttpServletRequest request, int type) {
    ArrayList<String> errors = new ArrayList<String>();
    ArrayList<String> pictureNames = new ArrayList<String>();

    DiskFileItemFactory factory = new DiskFileItemFactory();
    factory.setSizeThreshold(Constants.UPLOAD_SIZE_THRESHOLD);
    new File(Constants.TEMP_DIR).mkdirs();
    factory.setRepository(new File(Constants.TEMP_DIR));

    ServletFileUpload upload = new ServletFileUpload(factory);
    upload.setSizeMax(Constants.MAX_UPLOAD_SIZE);

    try {//from  w  w w. j av a  2 s .  c om
        List fileItems = upload.parseRequest(request);
        Iterator i = fileItems.iterator();

        while (i.hasNext()) {
            FileItem fileItem = (FileItem) i.next();
            String fileName = fileItem.getName();

            if (type == EXCEL_UPLOAD)
                errors.addAll(upload_excel(fileName, fileItem));
            else if (type == PICTURE_UPLOAD)
                errors.addAll(upload_picture(fileName, fileItem, pictureNames));
        }
    } catch (org.apache.commons.fileupload.FileUploadException e) {
        e.printStackTrace(System.out);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }

    if (type == PICTURE_UPLOAD)
        DataBaseTools.insertAndUpdateRecords(pictureNames);

    return errors;
}

From source file:controlador.SerCiudadano.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//w w w . j  av  a 2  s  .c o  m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    //Procesando el archivo .sql con los datos del cnr
    //en esta ruta se guarda temporalmente el archivo .sql
    Bitacora b = new Bitacora();
    String ruta = getServletContext().getRealPath("/") + "pages/procesos/";
    if (ServletFileUpload.isMultipartContent(request)) {
        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
        diskFileItemFactory.setSizeThreshold(40960);
        File repositoryPath = new File("/temp");
        diskFileItemFactory.setRepository(repositoryPath);
        ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
        servletFileUpload.setSizeMax(81920); // bytes
        upload.setSizeMax(307200); // 1024 x 300 = 307200 bytes = 300 Kb
        List listUploadFiles = null;
        FileItem item = null;
        try {
            listUploadFiles = upload.parseRequest(request);
            Iterator it = listUploadFiles.iterator();
            while (it.hasNext()) {
                item = (FileItem) it.next();
                //este es el archivo que se envia en el campo file
                if (!item.isFormField()) {
                    if (item.getSize() > 0) {
                        String nombre = item.getName();
                        String tipo = item.getContentType();
                        long tamanio = item.getSize();
                        String extension = nombre.substring(nombre.lastIndexOf("."));
                        File archivo = new File(ruta, nombre);
                        item.write(archivo);
                        if (archivo.exists()) {
                            String script = ruta + "" + nombre;
                            //consulta para importar registros
                            if (ConsultasDTO.ejecutar(
                                    "copy padronelectoral from '" + script + "' with (delimiter ',')")) {
                                out.print("Registros importados correctamente");
                            } else {
                                out.print("Hubo un error");
                            }

                        } else {
                            out.println("FALLO AL GUARDAR. NO EXISTE " + archivo.getAbsolutePath() + "</p>");
                        }
                    }
                } else {
                    //ac recogemos los duis de los magistrados
                    if (item.getFieldName().equals("dui1")) {
                        b.setMagistrado1(item.getString());
                    }
                    if (item.getFieldName().equals("dui2")) {
                        b.setMagistrado2(item.getString());
                    }
                    if (item.getFieldName().equals("dui3")) {
                        b.setMagistrado3(item.getString());
                    }

                }
            }
            //registramos en la base de datos los duis de los magistrados
            //que autorizaron la insercion de datos CNR
            b.setAccion("Registro de datos CNR");
            if (BitacoraDTO.agregarBitacora(b)) {
                out.print("<br>Bitacora agregada");
            } else {
                out.print("<br>Hubo un error al agregar la bitacora");
            }

        } catch (FileUploadException e) {
            out.println("Error Upload: " + e.getMessage());
            e.printStackTrace();
        } catch (Exception e) {
            out.println("Error otros: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.config.xmldtd.FileUploader.java

public File upload(HttpServletRequest request) throws Exception {
    DiskFileItemFactory factory = new DiskFileItemFactory();
    factory.setSizeThreshold(1024000);//from  w  w  w  . j  av  a 2 s .c  o  m
    ServletFileUpload upload = new ServletFileUpload(factory);
    List<FileItem> fileItems = upload.parseRequest(request);
    outFile = saveTmpFile(fileItems);

    return outFile;
}

From source file:Emporium.Servlet.ServImportarDestinatario.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from   w ww. ja va  2s .c  o m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
    HttpSession sessao = request.getSession();
    String nomeBD = (String) sessao.getAttribute("nomeBD");
    if (nomeBD != null) {
        boolean isMultiPart = FileUpload.isMultipartContent(request);
        int idCliente = 0;
        int idDepartamento = 0;
        if (isMultiPart) {
            try {
                FileItemFactory factory = new DiskFileItemFactory();
                ServletFileUpload upload = new ServletFileUpload(factory);
                upload.setSizeMax(1024 * 1024 * 2);

                List items = upload.parseRequest(request);
                Iterator iter = items.iterator();
                FileItem itemImg = null;

                while (iter.hasNext()) {
                    FileItem item = (FileItem) iter.next();
                    if (item.isFormField()) {
                        if (item.getFieldName().equals("idCliente")) {
                            idCliente = Integer.parseInt(item.getString());
                        }
                        if (item.getFieldName().equals("idDepartamento")) {
                            idDepartamento = Integer.parseInt(item.getString());
                        }
                    }
                    if (!item.isFormField()) {
                        if (item.getName().length() > 0) {
                            itemImg = item;
                        }
                    }
                }

                if (!itemImg.getName().toUpperCase().endsWith(".CSV")
                        && !itemImg.getName().toUpperCase().endsWith(".TXT")) {
                    response.sendRedirect(
                            "Cliente/Cadastros/destinatario_lista.jsp?msg=Escolha um arquivo para importacao !");
                } else {
                    //CONSULTA DADOS DO CLIENTE/DEPARTAMENTO/CONTRATO
                    Clientes cli = contrCliente.consultaClienteById(idCliente, nomeBD);
                    if (cli != null) {
                        String condicao = ContrDestinatarioImporta.importaPedido(itemImg, idCliente,
                                idDepartamento, nomeBD);
                        response.sendRedirect("Cliente/Cadastros/destinatario_lista.jsp?msg=" + condicao);
                    } else {
                        response.sendRedirect(
                                "Cliente/Cadastros/destinatario_lista.jsp?msg=Cliente nao encontrado no banco de dados!");
                    }
                }
            } catch (FileUploadException ex) {
                response.sendRedirect(
                        "Cliente/Cadastros/destinatario_lista.jsp?msg=Falha no Upload do Arquivo de Importacao!\n"
                                + ex);
            } catch (Exception ex) {
                response.sendRedirect(
                        "Cliente/Cadastros/destinatario_lista.jsp?msg=Falha na importacao!\n" + ex);
            }

        }
    } else {
        response.sendRedirect("Cliente/Cadastros/destinatario_lista.jsp?msg=Sua sessao expirou!");
    }
}

From source file:controller.uploadPergunta8.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from  ww  w  .  j av a  2  s .  c o m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String idLocal = (String) request.getParameter("idLocal");
    String idModelo = (String) request.getParameter("idModelo");
    String equacaoAjustada = (String) request.getParameter("equacaoAjustada");
    String idEquacaoAjustada = (String) request.getParameter("idEquacaoAjustada");

    String name = "";
    //process only if its multipart content
    if (ServletFileUpload.isMultipartContent(request)) {
        try {
            List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);

            for (FileItem item : multiparts) {
                if (!item.isFormField()) {
                    name = new File(item.getName()).getName();
                    //                        item.write( new File(UPLOAD_DIRECTORY + File.separator + name));
                    item.write(new File(AbsolutePath + File.separator + name));
                }
            }

            //File uploaded successfully
            request.setAttribute("message", "File Uploaded Successfully");
        } catch (Exception ex) {
            request.setAttribute("message", "File Upload Failed due to " + ex);
        }

    } else {
        request.setAttribute("message", "Sorry this Servlet only handles file upload request");
    }
    equacaoAjustada = equacaoAjustada.replace("+", "%2B");
    RequestDispatcher view = getServletContext().getRequestDispatcher(
            "/novoLocalPergunta8?id=" + idLocal + "&nomeArquivo=" + name + "&idModelo=" + idModelo
                    + "&equacaoAjustada=" + equacaoAjustada + "&idEquacaoAjustada=" + idEquacaoAjustada);
    view.forward(request, response);

    //        request.getRequestDispatcher("/novoLocalPergunta3?id="+idLocal+"&fupload=1&nomeArquivo="+name).forward(request, response);
    // request.getRequestDispatcher("/novoLocalPergunta4?id="+idLocal+"&nomeArquivo="+name).forward(request, response);

}

From source file:com.openhr.company.UploadCompLicenseFile.java

@Override
public ActionForward execute(ActionMapping map, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    // checks if the request actually contains upload file
    if (!ServletFileUpload.isMultipartContent(request)) {
        PrintWriter writer = response.getWriter();
        writer.println("Request does not contain upload data");
        writer.flush();/*w ww . j a v  a  2 s  .c  om*/
        return map.findForward("HRHome");
    }

    // configures upload settings
    DiskFileItemFactory factory = new DiskFileItemFactory();
    factory.setSizeThreshold(THRESHOLD_SIZE);
    factory.setRepository(new File(System.getProperty("java.io.tmpdir")));

    ServletFileUpload upload = new ServletFileUpload(factory);
    upload.setSizeMax(MAX_REQUEST_SIZE);

    // constructs the directory path to store upload file
    String uploadPath = UPLOAD_DIRECTORY;
    // creates the directory if it does not exist
    File uploadDir = new File(uploadPath);
    if (!uploadDir.exists()) {
        uploadDir.mkdir();
    }

    try {
        // parses the request's content to extract file data
        List formItems = upload.parseRequest(request);
        Iterator iter = formItems.iterator();

        // iterates over form's fields
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();
            // processes only fields that are not form fields
            if (!item.isFormField()) {
                String fileName = new File(item.getName()).getName();
                String filePath = uploadPath + File.separator + fileName;
                File storeFile = new File(filePath);

                // saves the file on disk
                item.write(storeFile);

                // Read the file object contents and parse it and store it in the repos
                FileInputStream fstream = new FileInputStream(storeFile);
                DataInputStream in = new DataInputStream(fstream);
                BufferedReader br = new BufferedReader(new InputStreamReader(in));
                String strLine;

                //Read File Line By Line
                while ((strLine = br.readLine()) != null) {
                    System.out.print("Processing line - " + strLine);

                    String[] lineColumns = strLine.split(COMMA);

                    if (lineColumns.length < 8) {
                        br.close();
                        in.close();
                        fstream.close();
                        throw new Exception("The required columns are missing in the line - " + strLine);
                    }

                    // Format is - CompID,CompName,Branch,Address,From,To,LicenseKey,FinStartMonth
                    String companyId = lineColumns[0];
                    String companyName = lineColumns[1];
                    String branchName = lineColumns[2];
                    String address = lineColumns[3];
                    String fromDateStr = lineColumns[4];
                    String toDateStr = lineColumns[5];
                    String licenseKey = lineColumns[6];
                    String finStartMonthStr = lineColumns[7];

                    Date fromDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.ENGLISH)
                            .parse(fromDateStr);
                    Date toDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.ENGLISH).parse(toDateStr);
                    address = address.replace(";", ",");

                    List<Company> eComp = CompanyFactory.findByName(companyName);
                    if (eComp == null || eComp.isEmpty()) {
                        Company company = new Company();
                        company.setCompanyId(companyId);
                        company.setName(companyName);
                        company.setFystart(Integer.parseInt(finStartMonthStr));

                        Branch branch = new Branch();
                        branch.setAddress(address);
                        branch.setCompanyId(company);
                        branch.setName(branchName);

                        Licenses license = new Licenses();
                        license.setActive(1);
                        license.setCompanyId(company);
                        license.setFromdate(fromDate);
                        license.setTodate(toDate);
                        license.formLicenseKey();

                        System.out.println("License key formed - " + license.getLicensekey());
                        System.out.println("License key given - " + licenseKey);
                        if (license.getLicensekey().equalsIgnoreCase(licenseKey)) {
                            CompanyFactory.insert(company);
                            BranchFactory.insert(branch);
                            LicenseFactory.insert(license);
                        } else {
                            br.close();
                            in.close();
                            fstream.close();

                            throw new Exception("License is tampared. Contact Support.");
                        }
                    } else {
                        // Company is present, so update it.
                        Company company = eComp.get(0);
                        List<Licenses> licenses = LicenseFactory.findByCompanyId(company.getId());

                        Licenses newLicense = new Licenses();
                        newLicense.setActive(1);
                        newLicense.setCompanyId(company);
                        newLicense.setFromdate(fromDate);
                        newLicense.setTodate(toDate);
                        newLicense.formLicenseKey();

                        System.out.println("License key formed - " + newLicense.getLicensekey());
                        System.out.println("License key given - " + licenseKey);

                        if (newLicense.getLicensekey().equalsIgnoreCase(licenseKey)) {
                            for (Licenses lic : licenses) {
                                if (lic.getActive().compareTo(1) == 0) {
                                    lic.setActive(0);
                                    LicenseFactory.update(lic);
                                }
                            }

                            LicenseFactory.insert(newLicense);
                        } else {
                            br.close();
                            in.close();
                            fstream.close();

                            throw new Exception("License is tampared. Contact Support.");
                        }
                    }
                }

                //Close the input stream
                br.close();
                in.close();
                fstream.close();
            }
        }
        System.out.println("Upload has been done successfully!");
    } catch (Exception ex) {
        System.out.println("There was an error: " + ex.getMessage());
        ex.printStackTrace();
    }

    return map.findForward("CompLicHome");
}