I'm trying to retrieve a file from a JSP form. I'm using Tomcat 9.0 / Java 8
When I compile, I got the messages :
addHabit.java:56: error: cannot find symbol String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString();
symbol: method getSubmittedFileName() location: variable filePart of type Part
addHabit.java:56: error: cannot find symbol String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString();
symbol: variable Paths
My code is pretty simple and looks like everything I found here and on the web :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;
import com.microsoft.sqlserver.jdbc.*;
// Appelé par le JSP addConfigType.jsp via l'action du formulaire
@MultipartConfig(
  fileSizeThreshold = 1024 * 1024 * 1, // 1 MB
  maxFileSize = 1024 * 1024 * 10,      // 10 MB
  maxRequestSize = 1024 * 1024 * 100   // 100 MB
)
public class addHabit extends HttpServlet{ 
 
   public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
    {
        HttpSession session = request.getSession(false);
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();     
        String url="myURL";
        
        Part filePart = request.getPart("monfichier");          
        String fileName =  Paths.get(filePart.getSubmittedFileName()).getFileName().toString();             
         for (Part part : request.getParts()) {
            part.write(url);                
        }
    }
}
I compile using javax.servlet-api-3.0.1 According to this post How can I upload files to a server using JSP/Servlet? it should be fine
Can you help me ?
 
     
    