Cannot compile for FileUpload class
Because of problems using org.apache.commons.fileupload.* with tomcat 10 (see https://www.linuxquestions.org/quest...-a-4175710078/) I am trying to instead use org.apache.tomcat.util.http.fileupload.*. I'm referring to the class definition: https://tomcat.apache.org/tomcat-10....ileUpload.html. I am importing:
Code:
<%@ page import="org.apache.tomcat.util.http.fileupload.*" %> Code:
An error occurred at line: [228] in the jsp file: [/1099R-Etrans.jsp] What am I doing wrong? |
Did you try to place your jars in WEB-INF/lib? It seems a common issue.
https://bytes.com/topic/java/answers...ages-using-jsp https://stackoverflow.com/questions/...apache-commons |
I guess there is no need to use new with getFileItemFactory():
Code:
228: FileItemFactory factory = getFileItemFactory(); // Create a factory for disk-based file items |
Quote:
Quote:
Quote:
Code:
An error occurred at line: [228] in the jsp file: [/1099R-Etrans.jsp] However, the package I'm trying to use now is org.apache.tomcat.util.http.fileupload, not the org.apache.commons.fileupload. So, there is something else afoot than the javax/jakarta issue. Maybe Tomcat 10.0 is a version whose time has not yet come? Has anyone actually implemented 10.0? With FileUpload? |
I've made some modest progress on this. I'm trying to use the org.apache.tomcat.util.http.fileupload package, which does exist in $CATALINA_HOME/lib/tomcat-coyote.jar by installation default. I'm following the example shown here https://tomcat.apache.org/tomcat-8.5...e-summary.html. I have:
Code:
<%@ page import="org.apache.tomcat.util.http.fileupload.disk.*, Code:
An error occurred at line: [231] in the jsp file: [/1099R-Etrans.jsp] Can Java/JSP expert help me on this? can I cast/covert my 'request' object to HttpServletRequest? |
Solved! I was able to convert my Request HttpServletRequest to a RequestContext, credit goes to this post: https://stackoverflow.com/questions/...ttpservletrequ. Then it was a matter of doing more web searchs to find the class definitions I needed to import. The following now works:
Code:
<%@ page import="org.apache.tomcat.util.http.fileupload.*, I heartily wish that when people gave example HowTo Java code on the Web that they would specify which class definitions were needed. It seems they almost never do. I end up spending significant time searching multiple sites to figure out what I need to import. I hope this post helps someone with the same problem, and I have made sure to include the imports I needed. Thanks to all. |
All times are GMT -5. The time now is 03:17 PM. |