Example usage for org.apache.commons.fileupload FileItem getFieldName

List of usage examples for org.apache.commons.fileupload FileItem getFieldName

Introduction

In this page you can find the example usage for org.apache.commons.fileupload FileItem getFieldName.

Prototype

String getFieldName();

Source Link

Document

Returns the name of the field in the multipart form corresponding to this file item.

Usage

From source file:gov.nih.nci.evs.browser.servlet.UploadServlet.java

/**
 * Process the specified HTTP request, and create the corresponding HTTP
 * response (or forward to another web component that will create it).
 *
 * @param request The HTTP request we are processing
 * @param response The HTTP response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet exception occurs
 *//*from  w  w  w  . j av  a2 s.c om*/

public void execute(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    // Determine request by attributes
    String action = (String) request.getParameter("action");
    String type = (String) request.getParameter("type");

    System.out.println("(*) UploadServlet ...action " + action);
    if (action == null) {
        action = "upload_data";
    }

    DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();
    /*
     *Set the size threshold, above which content will be stored on disk.
     */
    fileItemFactory.setSizeThreshold(1 * 1024 * 1024); //1 MB
    /*
     * Set the temporary directory to store the uploaded files of size above threshold.
     */
    //fileItemFactory.setRepository(tmpDir);

    ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);
    try {
        /*
         * Parse the request
         */
        List items = uploadHandler.parseRequest(request);
        Iterator itr = items.iterator();
        while (itr.hasNext()) {
            FileItem item = (FileItem) itr.next();
            /*
             * Handle Form Fields.
             */
            if (item.isFormField()) {
                System.out.println("File Name = " + item.getFieldName() + ", Value = " + item.getString());
                //String s = convertStreamToString(item.getInputStream(), item.getSize());
                //System.out.println(s);

            } else {
                //Handle Uploaded files.
                System.out.println("Field Name = " + item.getFieldName() + ", File Name = " + item.getName()
                        + ", Content type = " + item.getContentType() + ", File Size = " + item.getSize());

                String s = convertStreamToString(item.getInputStream(), item.getSize());
                //System.out.println(s);

                request.getSession().setAttribute("action", action);

                if (action.compareTo("upload_data") == 0) {
                    request.getSession().setAttribute("codes", s);
                } else {
                    Mapping mapping = new Mapping().toMapping(s);

                    System.out.println("Mapping " + mapping.getMappingName() + " uploaded.");
                    System.out.println("Mapping version: " + mapping.getMappingVersion());

                    MappingObject obj = mapping.toMappingObject();
                    HashMap mappings = (HashMap) request.getSession().getAttribute("mappings");
                    if (mappings == null) {
                        mappings = new HashMap();
                    }
                    mappings.put(obj.getKey(), obj);
                    request.getSession().setAttribute("mappings", mappings);
                }
            }
        }
    } catch (FileUploadException ex) {
        log("Error encountered while parsing the request", ex);
    } catch (Exception ex) {
        log("Error encountered while uploading file", ex);
    }

    //long ms = System.currentTimeMillis();

    if (action.compareTo("upload_data") == 0) {
        if (type.compareTo("codingscheme") == 0) {
            response.sendRedirect(
                    response.encodeRedirectURL(request.getContextPath() + "/pages/codingscheme_data.jsf"));
        } else if (type.compareTo("ncimeta") == 0) {
            response.sendRedirect(
                    response.encodeRedirectURL(request.getContextPath() + "/pages/ncimeta_data.jsf"));
        } else if (type.compareTo("valueset") == 0) {
            response.sendRedirect(
                    response.encodeRedirectURL(request.getContextPath() + "/pages/valueset_data.jsf"));
        }
    } else {
        response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/home.jsf"));
    }

}

From source file:bijian.util.upload.MyMultiPartRequest.java

private void processNormalFormField(FileItem item, String charset) throws UnsupportedEncodingException {
    LOG.debug("Item is a normal form field");
    List<String> values;
    if (params.get(item.getFieldName()) != null) {
        values = params.get(item.getFieldName());
    } else {//from w ww.j av  a  2  s .  c om
        values = new ArrayList<String>();
    }

    // note: see http://jira.opensymphony.com/browse/WW-633
    // basically, in some cases the charset may be null, so
    // we're just going to try to "other" method (no idea if this
    // will work)
    if (charset != null) {
        values.add(item.getString(charset));
    } else {
        values.add(item.getString());
    }
    params.put(item.getFieldName(), values);
}

From source file:com.fredck.FCKeditor.connector.ConnectorServlet.java

/**
 * Manage the Post requests (FileUpload).<br>
 * /*from w w w  .  java 2  s .c  o  m*/
 * The servlet accepts commands sent in the following format:<br>
 * connector?Command=FileUpload&Type=ResourceType&CurrentFolder=FolderPath<br>
 * <br>
 * It store the file (renaming it in case a file with the same name exists)
 * and then return an HTML file with a javascript command in it.
 * 
 */
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    System.out.println("ConnectorServlet.doPost");
    if (debug)
        System.out.println("--- BEGIN DOPOST ---");

    response.setContentType("text/html; charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    PrintWriter out = response.getWriter();

    String commandStr = request.getParameter("Command");
    String typeStr = request.getParameter("Type");
    String currentFolderStr = request.getParameter("CurrentFolder");

    String currentPath = baseDir + typeStr + currentFolderStr;
    String currentDirPath = getServletContext().getRealPath(currentPath);

    if (debug)
        System.out.println(currentDirPath);

    String retVal = "0";
    String newName = "";

    if (!commandStr.equals("FileUpload"))
        retVal = "203";
    else {
        DiskFileUpload upload = new DiskFileUpload();
        try {
            List items = upload.parseRequest(request);

            Map fields = new HashMap();

            Iterator iter = items.iterator();
            while (iter.hasNext()) {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField())
                    fields.put(item.getFieldName(), item.getString());
                else
                    fields.put(item.getFieldName(), item);
            }
            FileItem uplFile = (FileItem) fields.get("NewFile");
            String fileNameLong = uplFile.getName();
            fileNameLong = fileNameLong.replace('\\', '/');
            String[] pathParts = fileNameLong.split("/");
            String fileName = pathParts[pathParts.length - 1];

            String nameWithoutExt = getNameWithoutExtension(fileName);
            String ext = getExtension(fileName);
            File pathToSave = new File(currentDirPath, fileName);
            int counter = 1;
            while (pathToSave.exists()) {
                newName = nameWithoutExt + "(" + counter + ")" + "." + ext;
                retVal = "201";
                pathToSave = new File(currentDirPath, newName);
                counter++;
            }
            uplFile.write(pathToSave);
        } catch (Exception ex) {
            retVal = "203";
        }

    }
    System.out.println("1111111111111111111111");
    out.println("<script type=\"text/javascript\">");
    out.println("window.parent.frames['frmUpload'].OnUploadCompleted(" + retVal + ",'" + newName + "');");
    out.println("</script>");
    out.flush();
    out.close();

    if (debug)
        System.out.println("--- END DOPOST ---");

}

From source file:com.ikon.servlet.admin.MimeTypeServlet.java

@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    log.debug("doPost({}, {})", request, response);
    request.setCharacterEncoding("UTF-8");
    String action = WebUtils.getString(request, "action");
    String userId = request.getRemoteUser();
    Session dbSession = null;/*from w  w w. j  av  a  2 s . com*/
    updateSessionManager(request);

    try {
        if (ServletFileUpload.isMultipartContent(request)) {
            InputStream is = null;
            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            List<FileItem> items = upload.parseRequest(request);
            MimeType mt = new MimeType();
            byte data[] = null;

            for (Iterator<FileItem> it = items.iterator(); it.hasNext();) {
                FileItem item = it.next();

                if (item.isFormField()) {
                    if (item.getFieldName().equals("action")) {
                        action = item.getString("UTF-8");
                    } else if (item.getFieldName().equals("mt_id")) {
                        mt.setId(Integer.parseInt(item.getString("UTF-8")));
                    } else if (item.getFieldName().equals("mt_name")) {
                        mt.setName(item.getString("UTF-8").toLowerCase());
                    } else if (item.getFieldName().equals("mt_extensions")) {
                        String[] extensions = item.getString("UTF-8").split(" ");
                        for (int i = 0; i < extensions.length; i++) {
                            mt.getExtensions().add(extensions[i].toLowerCase());
                        }
                    }
                } else {
                    is = item.getInputStream();
                    data = IOUtils.toByteArray(is);
                    mt.setImageMime(MimeTypeConfig.mimeTypes.getContentType(item.getName()));
                    is.close();
                }
            }

            if (action.equals("create")) {
                // Because this servlet is also used for SQL import and in that case I don't
                // want to waste a b64Encode conversion. Call it a sort of optimization.
                mt.setImageContent(SecureStore.b64Encode(data));
                long id = MimeTypeDAO.create(mt);
                MimeTypeConfig.loadMimeTypes();

                // Activity log
                UserActivity.log(userId, "ADMIN_MIME_TYPE_CREATE", Long.toString(id), null, mt.toString());
                list(userId, request, response);
            } else if (action.equals("edit")) {
                // Because this servlet is also used for SQL import and in that case I don't
                // want to waste a b64Encode conversion. Call it a sort of optimization.
                mt.setImageContent(SecureStore.b64Encode(data));
                MimeTypeDAO.update(mt);
                MimeTypeConfig.loadMimeTypes();

                // Activity log
                UserActivity.log(userId, "ADMIN_MIME_TYPE_EDIT", Long.toString(mt.getId()), null,
                        mt.toString());
                list(userId, request, response);
            } else if (action.equals("delete")) {
                MimeTypeDAO.delete(mt.getId());
                MimeTypeConfig.loadMimeTypes();

                // Activity log
                UserActivity.log(userId, "ADMIN_MIME_TYPE_DELETE", Long.toString(mt.getId()), null, null);
                list(userId, request, response);
            } else if (action.equals("import")) {
                dbSession = HibernateUtil.getSessionFactory().openSession();
                importMimeTypes(userId, request, response, data, dbSession);
                list(userId, request, response);
            }
        }
    } catch (DatabaseException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (FileUploadException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (SQLException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } finally {
        HibernateUtil.close(dbSession);
    }
}

From source file:application.controllers.admin.EditEmotion.java

private String uploadNewImage(HttpServletRequest request, HttpServletResponse response) {
    String linkImage = emotionSelected.linkImage;
    if (!ServletFileUpload.isMultipartContent(request)) {
        return "";
    }//from   ww  w. j av a  2s .  co m
    // configures upload settings
    DiskFileItemFactory factory = new DiskFileItemFactory();
    // maximum size that will be stored in memory
    factory.setSizeThreshold(UploadConstant.THRESHOLD_SIZE);
    // Location to save data that is larger than maxMemSize.
    factory.setRepository(new File(System.getProperty("java.io.tmpdir")));
    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);
    // maximum file size to be uploaded.
    upload.setFileSizeMax(UploadConstant.MAX_FILE_SIZE);
    upload.setSizeMax(UploadConstant.MAX_REQUEST_SIZE);

    // constructs the directory path to store upload file
    //groupEmotionId chinh la folder chua
    // creates the directory if it does not exist
    String[] arrLink = emotionSelected.linkImage.split("/");
    if (arrLink.length < 3) {
        return "";
    }
    try {
        List formItems = upload.parseRequest(request);
        Iterator iter = formItems.iterator();
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();
            // processes only fields that are not form fields
            if (item.isFormField()) {
                //form field
                if (item.getFieldName().equals("groupEmotion")) {
                    try {
                        if (emotionSelected.groupEmotionId != Integer.parseInt(item.getString())) {
                            //thay doi group id --> chuyen file sang folder tuong ung va thay doi imagelink
                            //chuyen file sang folder tuong ung theo group da chon

                            String sourcePath = Registry.get("imageHost") + emotionSelected.linkImage;
                            //item.getString --> groupEmotion chon
                            String desPath = Registry.get("imageHost") + "/emotions-image/" + item.getString()
                                    + "/" + arrLink[3];

                            File sourceDir = new File(sourcePath);
                            File desDir = new File(desPath);
                            if (sourceDir.exists()) {
                                FileUtils.copyFile(sourceDir, desDir);
                                sourceDir.delete();

                            }

                            emotionSelected.groupEmotionId = Integer.parseInt(item.getString());
                            linkImage = "/emotions-image/" + emotionSelected.groupEmotionId + "/" + arrLink[3];

                        }
                    } catch (NumberFormatException ex) {
                        ex.printStackTrace();
                    }
                }
                if (item.getFieldName().equals("description")) {
                    emotionSelected.description = item.getString();
                }
                if (item.getFieldName().equals("imageURL")) {
                    emotionSelected.linkImage = item.getString();

                }
            } else {

                String fileName = new File(item.getName()).getName();
                //file name bang empty khi ko upload new image
                if ("".equals(fileName)) {
                    continue;
                }
                String filePath = Registry.get("imageHost") + emotionSelected.linkImage;
                File newImage = new File(filePath);
                File oldImage = new File(filePath);
                // xoa image cu bi edit
                if (oldImage.exists()) {
                    oldImage.delete();
                }
                // save image moi vao  folder cua group id va cung ten moi image cu
                item.write(newImage);

                //save lai file cua image moi
                linkImage = "/emotions-image/" + emotionSelected.groupEmotionId + "/" + arrLink[3];
            }
        }

    } catch (Exception ex) {
        Logger.getLogger(EditEmotion.class.getName()).log(Level.SEVERE, null, ex);
    }
    return linkImage;

}

From source file:com.orinus.script.safe.jetty.SRequest.java

public void parseMultipartContent() {
    if (formFields != null && formFiles != null && formFileData != null)
        return;/*from w  w  w  .j  ava  2 s. com*/
    formFields = new HashMap<String, String>();
    formFiles = new HashMap<String, FileEntry>();
    formFileData = new HashMap<String, String>();
    try {
        DiskFileItemFactory factory = new DiskFileItemFactory();
        Controller controller = new Controller();
        factory.setRepository(new File(controller.getTempDir()));
        ServletFileUpload upload = new ServletFileUpload(factory);
        List items = upload.parseRequest(req);
        for (int i = 0; i < items.size(); i++) {
            FileItem item = (FileItem) items.get(i);
            if (item.isFormField()) {
                formFields.put(item.getFieldName(), item.getString());
            } else {
                FileEntry fe = new FileEntry();
                fe.fieldName = item.getFieldName();
                fe.contentType = item.getContentType();
                fe.filename = new File(item.getName()).getName();
                fe.fileSize = item.getSize();
                String filename = new File(controller.getTempDir(), fe.filename).getAbsolutePath();
                item.write(new File(filename));
                formFiles.put(fe.fieldName, fe);
                formFileData.put(fe.fieldName, filename);
            }
        }
    } catch (Exception e) {
    }
}

From source file:com.alibaba.citrus.service.requestcontext.parser.ParserRequestContextTests.java

@Test
public void multipartForm() throws Exception {
    assertEquals("hello", requestContext.getParameters().getString("myparam"));

    // ??file item
    FileItem fileItem = requestContext.getParameters().getFileItem("myfile");

    assertEquals("myfile", fileItem.getFieldName());
    assertEquals(new File(srcdir, "smallfile.txt"), new File(fileItem.getName()));
    assertFalse(fileItem.isFormField());
    assertEquals(new String("?".getBytes("GBK"), "8859_1"), fileItem.getString());
    assertEquals("?", fileItem.getString("GBK"));
    assertTrue(fileItem.isInMemory());//from  www . ja va  2  s . co  m

    // ?file items
    FileItem[] fileItems = requestContext.getParameters().getFileItems("myfile");
    String[] fileNames = requestContext.getParameters().getStrings("myfile");

    assertEquals(fileItems.length, fileNames.length);
    assertEquals(4, fileNames.length);

    assertEquals(new File(srcdir, "smallfile.txt"), new File(fileItems[0].getName()));
    assertEquals(new File(srcdir, "smallfile_.JPG"), new File(fileItems[1].getName())); // case insensitive
    assertEquals(new File(srcdir, "smallfile.gif"), new File(fileItems[2].getName()));
    assertEquals(new File(srcdir, "smallfile"), new File(fileItems[3].getName()));

    assertEquals(new File(srcdir, "smallfile.txt"), new File(fileNames[0]));
    assertEquals(new File(srcdir, "smallfile_.JPG"), new File(fileNames[1])); // case insensitive
    assertEquals(new File(srcdir, "smallfile.gif"), new File(fileNames[2]));
    assertEquals(new File(srcdir, "smallfile"), new File(fileNames[3]));

    // request??
    assertEquals("hello", newRequest.getParameter("myparam"));
    assertEquals(new File(srcdir, "smallfile.txt"), new File(newRequest.getParameter("myfile")));
}

From source file:com.javaweb.controller.SuaTinTucServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 *
 * @param request servlet request//  ww w  .ja v a2  s.c  om
 * @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, ParseException {
    response.setContentType("text/html;charset=UTF-8");
    request.setCharacterEncoding("UTF-8");

    //response.setCharacterEncoding("UTF-8");
    HttpSession session = request.getSession();
    String TieuDe = "", NoiDung = "", ngaydang = "", GhiChu = "", fileName = "";
    int idloaitin = 0, idTK = 0, idtt = 0;

    TintucService tintucservice = new TintucService();

    //File upload
    String folderupload = getServletContext().getInitParameter("file-upload");
    String rootPath = getServletContext().getRealPath("/");
    filePath = rootPath + folderupload;
    isMultipart = ServletFileUpload.isMultipartContent(request);
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();

    DiskFileItemFactory factory = new DiskFileItemFactory();
    // maximum size that will be stored in memory
    factory.setSizeThreshold(maxMemSize);
    // Location to save data that is larger than maxMemSize.
    factory.setRepository(new File("C:\\Windows\\Temp\\"));

    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);
    // maximum file size to be uploaded.
    upload.setSizeMax(maxFileSize);

    try {
        // Parse the request to get file items.
        List fileItems = upload.parseRequest(request);

        // Process the uploaded file items
        Iterator i = fileItems.iterator();

        while (i.hasNext()) {
            FileItem fi = (FileItem) i.next();
            if (!fi.isFormField()) {
                // Get the uploaded file parameters

                String fieldName = fi.getFieldName();
                fileName = fi.getName();
                String contentType = fi.getContentType();
                boolean isInMemory = fi.isInMemory();
                long sizeInBytes = fi.getSize();

                //change file name
                fileName = FileService.ChangeFileName(fileName);

                // Write the file
                if (fileName.lastIndexOf("\\") >= 0) {
                    file = new File(filePath + fileName.substring(fileName.lastIndexOf("\\")));
                } else {
                    file = new File(filePath + "/" + fileName.substring(fileName.lastIndexOf("\\") + 1));
                }
                fi.write(file);
                //                    out.println("Uploaded Filename: " + fileName + "<br>");
            }

            if (fi.isFormField()) {
                if (fi.getFieldName().equalsIgnoreCase("TieuDe")) {
                    TieuDe = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("NoiDung")) {
                    NoiDung = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("NgayDang")) {
                    ngaydang = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("GhiChu")) {
                    GhiChu = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("loaitin")) {
                    idloaitin = Integer.parseInt(fi.getString("UTF-8"));
                } else if (fi.getFieldName().equalsIgnoreCase("idtaikhoan")) {
                    idTK = Integer.parseInt(fi.getString("UTF-8"));
                } else if (fi.getFieldName().equalsIgnoreCase("idtt")) {
                    idtt = Integer.parseInt(fi.getString("UTF-8"));
                }
            }
        }

    } catch (Exception ex) {
        System.out.println(ex);
    }

    Date NgayDang = new SimpleDateFormat("yyyy-MM-dd").parse(ngaydang);

    Tintuc tt = tintucservice.GetTintucID(idtt);

    tt.setIdTaiKhoan(idTK);
    tt.setTieuDe(TieuDe);
    tt.setNoiDung(NoiDung);
    tt.setNgayDang(NgayDang);
    tt.setGhiChu(GhiChu);
    if (!fileName.equals("")) {
        if (tt.getImgLink() != null) {
            if (!tt.getImgLink().equals(fileName)) {
                tt.setImgLink(fileName);
            }
        } else {
            tt.setImgLink(fileName);
        }
    }

    boolean rs = tintucservice.InsertTintuc(tt);
    if (rs) {
        session.setAttribute("kiemtra", "1");
        response.sendRedirect("SuaTinTuc.jsp?idTintuc=" + idtt);
    } else {
        session.setAttribute("kiemtra", "0");
        response.sendRedirect("SuaTinTuc.jsp?idTintuc=" + idtt);
    }

    //        try (PrintWriter out = response.getWriter()) {
    //            /* TODO output your page here. You may use following sample code. */
    //            out.println("<!DOCTYPE html>");
    //            out.println("<html>");
    //            out.println("<head>");
    //            out.println("<title>Servlet SuaTinTucServlet</title>");            
    //            out.println("</head>");
    //            out.println("<body>");
    //            out.println("<h1>Servlet SuaTinTucServlet at " + request.getContextPath() + "</h1>");
    //            out.println("</body>");
    //            out.println("</html>");
    //        }
}

From source file:com.silverpeas.form.AbstractForm.java

/**
 * Gets the multipart data of the specified parameter.
 * @param items the items of the form with all of the multipart data.
 * @param parameterName the name of the parameter.
 * @return the item corresponding to the specified parameter.
 *///from   w  w  w.j a va2 s. com
private FileItem getParameter(final List<FileItem> items, final String parameterName) {
    FileItem fileItem = null;
    for (FileItem item : items) {
        if (parameterName.equals(item.getFieldName())) {
            fileItem = item;
            break;
        }
    }
    return fileItem;
}

From source file:edu.fullerton.ldvservlet.Upload.java

private int addFile(FileItem item, HashMap<String, String> params, Page vpage, String userName,
        ImageTable imageTable) throws ServletException {
    int ret = 0;/*from   w  ww.  j  av  a 2s  .c  om*/

    String fieldName = item.getFieldName();
    String fileName = item.getName();
    String contentType = item.getContentType();
    boolean isInMemory = item.isInMemory();
    long sizeInBytes = item.getSize();
    if (sizeInBytes >= 100 && !fileName.isEmpty()) {
        Matcher m = fileNumPat.matcher(fieldName);
        if (m.find()) {
            String descriptionName = "desc" + m.group(1);
            String description = params.get(descriptionName);
            description = description == null ? "" : description;
            if (isValid(contentType)) {
                try {
                    byte[] buf = item.get();
                    ByteArrayInputStream bis = new ByteArrayInputStream(buf);
                    int imgId = imageTable.addImg(userName, bis, contentType);
                    if (!description.isEmpty()) {
                        imageTable.addDescription(imgId, description);
                    }
                    ret = imgId;
                    vpage.add("uploaded " + fileName + " - " + description);
                    vpage.addBlankLines(1);
                } catch (IOException | SQLException | NoSuchAlgorithmException ex) {
                    String ermsg = "Error reading data for " + fileName + ex.getClass().getSimpleName() + " "
                            + ex.getLocalizedMessage();
                    vpage.add(ermsg);
                    vpage.addBlankLines(1);
                }
            } else {
                vpage.add(String.format("The file: %1$s has an unsuported mime type: %2$s", fileName,
                        contentType));
                vpage.addBlankLines(1);
            }
        }
    }
    return ret;
}