Ho Mark,

I still do not understand everything.

I understood the following:

1)
>From Tomcat 10 and onwards there has been a move from Java EE to Jakarta EE as 
>part of the transfer of Java EE to the Eclipse Foundation, the primary package 
>for all implemented APIs has changed from javax.* to jakarta.*.

2)
The package commons-fileupload has dependencies to the old javax package.

3) I can remove the commons-fileupload-* jar files from my application:
/u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib:
commons-fileupload-1.5-test-sources.jar
commons-fileupload-1.5-tests.jar
commons-fileupload-1.5-sources.jar
commons-fileupload-1.5-javadoc.jar
commons-fileupload-1.5.jar

4)
I do not need a specific configuration for Tomcat 10.

5)
I can use the already available servlet-api jar package from Tomcat 10.



I can go for Option 2.
So, I guess I need to re-write my JSP page as if it was for Java EE for Tomcat 
9 (or earlier versions) for instance, correct?
You wrote "Write your web application using the Java EE APIs and then deploy it 
to webapps-javaee rather than webapps and Tomcat will use the migration
tool to convert your web application for you".
What is webapps-javaee ? How can I use it if I have a JSP page for Java EE.

Kind Regards,

Lauri
________________________________
From: Mark Thomas <ma...@apache.org>
Sent: Tuesday, May 30, 2023 9:22 AM
To: users@tomcat.apache.org <users@tomcat.apache.org>
Subject: Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 
10

On 30/05/2023 07:17, Lauri wrote:
> Hi Mark,
>
> If I understand well:
>
> a) I should remove the commons*.jar files from my 
> /u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib.

No. commons-fileupload-1.5.jar (in some form) can stay (see option 1).

> b) I do not need to have a specific configuration for Tomcat 10 to use 
> servlet-api and jakarta EE packages.

Correct.

> I still do not understand the following:
>
> c) Do I use the correct servlet-api jar package ?

Yes.

> You answered:
> If you are using Tomcat 10, you need to use the Jakarta EE package
> names. You can't use the Java EE package names. You can't use any
> library that uses the Java EE package names.
>
> But the servlet-api is already included in the Tomcat 10 lib.
> What's wrong with this ?

commons-fileupload-1.5.jar uses the Java EE API. It will not work with
Tomcat 10.

> I use these modules in the JSP page:
> <%@ page import="org.apache.commons.fileupload.*" %>
> <%@ page import="org.apache.commons.fileupload.disk.*" %>
> <%@ page import="org.apache.commons.fileupload.servlet.*" %>
> <%@ page import="java.io.*" %>
> <%@ page import="java.util.*" %>
> <%@ page import="jakarta.servlet.*" %>
> <%@ page import="jakarta.servlet.http.*" %>
> <%@ page import="jakarta.sql.*" %>
> <%@ page import="java.sql.*" %>
> <%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
> <%@ page import="org.apache.commons.fileupload.FileItemFactory" %>
>
> What's wrong with this ?

See above.

> e) Option 1, 2, 3
>
> The JSP page has not been migrated from Tomcat X to Tomcat 10.
> It has been directly deployed in Tomcat 10.
>
> What is wrong in the code of my JSP page ?
> Thanks by advance for any indications.

There is nothing wrong with the code in the JSP page but the library you
are trying to use (commons-fileupload-1.5.jar) will not work with Tomcat 10.

The quickest fix is probably option 1:
Use the Tomcat migration tool for Jakarta EE to convert
commons-fileupload-1.5.jar from from Java EE to Jakarta EE and then use
the converted JAR rather than the original.

The best solution is probably the one Thomas pointed out:

Option 4:
Stop using commons-fileupload-1.5.jar and use the methods provided by
the Servlet API to handle file uploads.

Mark


>
> Kind Regards,
>
> Lauri
>
> ________________________________
> From: Mark Thomas <ma...@apache.org>
> Sent: Monday, May 29, 2023 5:44 PM
> To: users@tomcat.apache.org <users@tomcat.apache.org>
> Subject: Re: Cannot upload an image file from a deployed JSP page in Tomcat 10
>
> On 29/05/2023 10:36, Lauri wrote:
>
>>   From Tomcat 10 and onwards there has been a move from Java EE to Jakarta 
>> EE as part of the transfer of Java EE to the Eclipse Foundation, the primary 
>> package for all implemented APIs has changed from javax.* to jakarta.*.
>
> Note the above.
>
> <snip />
>
>> I have these libraries for the TESTS application:
>> /u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib:
>> commons-fileupload-1.5-test-sources.jar
>> commons-fileupload-1.5-tests.jar
>> commons-fileupload-1.5-sources.jar
>> commons-fileupload-1.5-javadoc.jar
>
> You should not have any of the above in your web application.
>
>> commons-fileupload-1.5.jar
>
> That library uses the Java EE APIs so it won't work with Tomcat 10 as
> you have discovered.
>
>> Does someone know if this is related to a bug ?
>
> No. There is no bug.
>
>> Do I use the correct servlet-api jar package ?
>
> If you are using Tomcat 10, you need to use the Jakarta EE package
> names. You can't use the Java EE package names. You can't use any
> library that uses the Java EE package names.
>
>> Do Tomcat 10 need to be specifically configured for using servlet-api and 
>> jakarta EE packages ?
>
> No.
>
>> Does someone know what can be the problem ?
>
> See above. You are trying to use a Java EE library with Jakarta EE.
>
>> Thanks by advance for any tip(s) and/or suggestion(s).
>
> Option 1.
> Write your web application using the Jakarta EE APIs.
> Use the Tomcat migration tool for Jakarta EE to convert
> commons-fileupload-1.5.jar from from Java EE to Jakarta EE (and any
> other libraries using the Java EE APIs).
> Deploy your web application with the converted JARs.
>
> Option 2.
> Write your web application using the Java EE APIs and then deploy it to
> webapps-javaee rather than webapps and Tomcat will use the migration
> tool to convert your web application for you.
>
> Option 3.
> Write your web application using the Java EE APIs and convert it to
> Jkarata EE using the migration tool. Once converted, deploy it to the
> webapps directory.
>
> Note: If you use any deprecated Java EE APIs you may still see failures
> after conversion as Jakarta EE 10 most of the deprecated APIs.
>
> 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

Reply via email to