On 10/11/2023 16:49, Mark Foley wrote:
I recently upgraded 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
thanks to postings on stackoverflow, but now that I've
upgraded to 10.1.13 it is broken again! Here's the error I get:
An error occurred at line: [40] in the jsp file: [/schDistImportResults.jsp]
The method isMultipartContent(ServletRequestContext) is undefined for the type
FileUpload
Tomcat's internal fork of Commons FileUpload isn't intended for
applications to use. It is not a full fork - just a limited subset of
the functionality Tomcat needs to implement the Servley upload API.
If you want to use Commons File Upload, add the JAR to your web
application and use it.
Alternatively, if you want to use the Servlet upload API then use that.
If the javax.sevlet -> jakarta.servlet transition means you can't use
your preferred version of Commons File Upload in Tomcat 10.1.x (very
likely) then run your preferred version of Commons File Upload through
Tomcat's migration tool for Jakarta EE and use the converted version of
Commons File Upload in your web application.
Depending on Tomcat internals is very likely to lead to breakage.
Mark
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
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 request
I have quite a few programs that use the FileUpload methods. Does anyone know
how to fix this latest breakage?
Thanks --Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org