FileUpload class not working with Tomcat 10.1
by mfoley from LinuxQuestions.org on (#6FNF3)
I recently upgreaded from Tomcat 10.0.17 to 10.1.13. When I previously upgraded from 9.0.41 to 10.0.17 (back in 2/22) the FileUpload class broke. I fixed that (https://www.linuxquestions.org/quest...ss-4175710186/), but now that I've upgraded to 10.1.13 it is broken again! Here's the error I get:
Code:> An error occurred at line: [40] in the jsp file: [/schDistImportResults.jsp]
> The method isMultipartContent(ServletRequestContext) is undefined for the type FileUpload
> 37: String programName = "$RCSfile: schDistImportResults.jsp,v $";
> 38: programName = programName.substring(programName.indexOf(':') + 2,programName.indexOf(','));
> 39:
> 40: boolean isMultipart = FileUpload.isMultipartContent(new ServletRequestContext(request));
> 41:
>
> An error occurred at line: [133] in the jsp file: [/schDistImportResults.jsp]
> ServletFileUpload cannot be resolved to a type
> 130: stmt = con.createStatement();
> 131:
> 132: DiskFileItemFactory factory = new DiskFileItemFactory(); // Create a factory for disk-based file items
> 133: ServletFileUpload upload = new ServletFileUpload(factory); // Create a new file upload handler
> 134: List items = upload.parseRequest(new ServletRequestContext(request)); // Parse the request
> 135: Iterator iter = items.iterator(); // Process the uploaded items
> 136: FileItem item = null;
>I've checked the RELEASE-NOTES, FAQ and searched the web. I've checked the UploadFile class (no clue) and looked for examples, but none resembled my app. I tried reverting back to the program version I had with 9.0.41, but that didn't work.
Here is all I changed in the program between Tomcat versions 9.0.41 and 10.0.17 (which worked):
Code:26,28c26,28
< <%@ page import="org.apache.commons.fileupload.*,
< org.apache.commons.fileupload.disk.*,
< org.apache.commons.fileupload.servlet.*,
---
> <%@ page import="org.apache.tomcat.util.http.fileupload.*,
> org.apache.tomcat.util.http.fileupload.disk.*,
> org.apache.tomcat.util.http.fileupload.servlet.*,
40c40
< boolean isMultipart = FileUpload.isMultipartContent(request);
---
> boolean isMultipart = FileUpload.isMultipartContent(new ServletRequestContext(request));
134c134
< List items = upload.parseRequest(request); // Parse the request
---
> List items = upload.parseRequest(new ServletRequestContext(request)); // Parse the requestDoes anyone know how to fix this latest breakage?
Code:> An error occurred at line: [40] in the jsp file: [/schDistImportResults.jsp]
> The method isMultipartContent(ServletRequestContext) is undefined for the type FileUpload
> 37: String programName = "$RCSfile: schDistImportResults.jsp,v $";
> 38: programName = programName.substring(programName.indexOf(':') + 2,programName.indexOf(','));
> 39:
> 40: boolean isMultipart = FileUpload.isMultipartContent(new ServletRequestContext(request));
> 41:
>
> An error occurred at line: [133] in the jsp file: [/schDistImportResults.jsp]
> ServletFileUpload cannot be resolved to a type
> 130: stmt = con.createStatement();
> 131:
> 132: DiskFileItemFactory factory = new DiskFileItemFactory(); // Create a factory for disk-based file items
> 133: ServletFileUpload upload = new ServletFileUpload(factory); // Create a new file upload handler
> 134: List items = upload.parseRequest(new ServletRequestContext(request)); // Parse the request
> 135: Iterator iter = items.iterator(); // Process the uploaded items
> 136: FileItem item = null;
>I've checked the RELEASE-NOTES, FAQ and searched the web. I've checked the UploadFile class (no clue) and looked for examples, but none resembled my app. I tried reverting back to the program version I had with 9.0.41, but that didn't work.
Here is all I changed in the program between Tomcat versions 9.0.41 and 10.0.17 (which worked):
Code:26,28c26,28
< <%@ page import="org.apache.commons.fileupload.*,
< org.apache.commons.fileupload.disk.*,
< org.apache.commons.fileupload.servlet.*,
---
> <%@ page import="org.apache.tomcat.util.http.fileupload.*,
> org.apache.tomcat.util.http.fileupload.disk.*,
> org.apache.tomcat.util.http.fileupload.servlet.*,
40c40
< boolean isMultipart = FileUpload.isMultipartContent(request);
---
> boolean isMultipart = FileUpload.isMultipartContent(new ServletRequestContext(request));
134c134
< List items = upload.parseRequest(request); // Parse the request
---
> List items = upload.parseRequest(new ServletRequestContext(request)); // Parse the requestDoes anyone know how to fix this latest breakage?