0


I'm doing a java web application that manage online auctions. At a certain point in the application the user can sell a product, so I have built a page where there is a form; in this form I have to handle the file upload using Oreilly Multipartrequest library. When I click the submit button a servlet should handle all the parameters, add the product on the database, and then redirect to the users page, but instead of doing it, the application hangs in a blank page. I'm using netbeans so I have checked the logs, but I can't find any errors; I have also checked on the logs inside the tomcat folder, but again I can't any errors. I don't know what to do neither where to search the solution.

Here is the part of the code that handle the upload:

try {

        MultipartRequest multi =
            new MultipartRequest(request, getServletContext().getRealPath("/img"), 10*1024*1024,
            "ISO-8859-1", new DefaultFileRenamePolicy());



        Enumeration files = multi.getFileNames();
        while (files.hasMoreElements()) {
            name = (String)files.nextElement();
            filename = multi.getFilesystemName(name);
            // String originalFilename = multi.getOriginalFileName(name);
            // String type = multi.getContentType(name);
            File f = multi.getFile(name);

            if (f != null) {
                session.setAttribute("success", "file written correctly");
            }
        }
    } catch (IOException IEx) {
        this.getServletContext().log("Error reading saving file");
    }

Am I doing something wrong, or my idea is correct?

P.S. If the user decide not to upload any picture, I have to put on the database a default picture.

DamianFox
  • 902
  • 3
  • 20
  • 45

0 Answers0