GlassFish Duplicating Directory

0

When saving a photo, instead of creating the directory it ends up doubling, apparently it puts the first directory of the Glassfish server and in the other one that I mentioned, being a layman I can not identify the error, can you see the error?

  

Error sending file: java.io.FileNotFoundException: C: \ Users \ gfalc \ AppData \ Roaming \ NetBeans \ 8.2 \ config \ GF_4.1.1 \ domain1 \ generated \ jsp \ (The syntax for the filename, directory name, or volume label is incorrect)

    String SAVE_DIR = "/../../web/img";//Glassfish

public String[] up(HttpServletRequest request, HttpServletResponse response)
        throws ServletException {
    String[] fileName = null, tipo = null;
    try {

        String appPath = request.getServletContext().getRealPath("");


        String savePath = appPath + SAVE_DIR;


        System.out.println("Aplicativo path:" + savePath);


        File saveDir = new File(savePath);
        if (!saveDir.exists()) {
            saveDir.mkdir();
        }
        //Cria uma lista de nome de arquivos
        fileName = new String[request.getParts().size()];
        int x = 0;

        //Varre todos os campos do formulario e pega apenas os arquivos de foto
        for (Part part : request.getParts()) {
            if (part.getSubmittedFileName() != null) {
                tipo = part.getContentType().split("/");
                if (tipo[1].length() <= 4) {
                    fileName[x] = br.com.lojagames.util.Crypt.md5(part.getSubmittedFileName()) + "." + tipo[1];
                    part.write(savePath + File.separator + fileName[x]);
                    x++;
                }
            }
        }
    
asked by anonymous 07.07.2017 / 00:42

0 answers