I am updating Jetty9 to Jetty11. I updated my package from javax.servlet to jakarta.servlet because servlet 5.0 is the prerequisite for Jetty11. but the problem is when I am using commons-fileupload`-1.4.jar as it is still using java.servlet package.
javax.servlet.http.HttpServletRequest.ServletFileUpload.isMultipartContent(request)
The above method is expecting argument from java.servlet package.
Latest version for commons-fileupload - https://search.maven.org/classic/#search%7Cga%7C1%7Ca%3A%22commons-fileupload%22%20AND%20g%3A%22commons-fileupload%22
Do we have any way to overcome this problem?
commons-fileupload
is not required from Servlet 3.1 onwards.
In fact, using commons-fileupload
in combination with the a container that supports Servlet spec 3.1 (or newer) is actually not recommended.
There hasn't even been a release of commons-fileupload
since 2018, and no releases that support Servlet 3.1 or newer (the last release of commons-fileupload
supports Servlet 2.4 and older)
Why?
The Multipart features are built into the Servlet spec since 3.1.
Every server that supports Servlet 3.1 supports multipart file upload now.
That includes Jetty 9.
Use HttpServletRequest.getPart()
API in code.
You configure it via either the @MultipartConfig
annotation and/or the <multipart-config>
descriptor element in your WEB-INF/web.xml
See: https://docs.oracle.com/javaee/7/tutorial/servlets011.htm
See also past answers on these features.