Here is the problem: when build a maven project, and try to convert it to Dynamic Web Project, the Apache Tomcat v9.0 couldn't be selected.
The Tomcat has configure successfully that it could show web at loacalhost:8080/, but it still couldn't be selected.
When in Project Facets
preferences view, if the Dynamic Web Project
facet is selected the following help text could appear on Details
tab.
Adds support for the Java or Jakarta Servlet API, for generation of dynamic Web page content.
So you must choose a version of Dynamic Web Project
that maps to the version of the Jakarta Servlet technology (Wikipedia) supported by your chosen version of Tomcat.
See list of supported Servlet API versions by Tomcat version. Tomcat 9.0.x supports Servlet 4.0, and requires Java 8+. Find the Servlet 4.0 specification and Javadoc here.
As an alternative, servlet supported versions can be found by inspecting servlet-api.jar
from tomcat lib
jar -tf /home/lmc/projects/bin/apache-tomcat-9.0.19/lib/servlet-api.jar | grep 'web-app'
Result
javax/servlet/resources/web-app_2_2.dtd
javax/servlet/resources/web-app_2_3.dtd
javax/servlet/resources/web-app_2_4.xsd
javax/servlet/resources/web-app_2_5.xsd
javax/servlet/resources/web-app_3_0.xsd
javax/servlet/resources/web-app_3_1.xsd
javax/servlet/resources/web-app_4_0.xsd
For tomcat 10
TZ='UTC' jar -tvf /home/lmc/projects/bin/apache-tomcat-10.1.24/lib/servlet-api.jar | grep 'web-app'
Result
16219 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_2_2.dtd
30251 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_2_3.dtd
39466 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_2_4.xsd
45121 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_2_5.xsd
10820 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_3_0.xsd
12638 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_3_1.xsd
14106 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_4_0.xsd
12747 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_5_0.xsd
12747 Fri Feb 01 00:00:00 UTC 1980 jakarta/servlet/resources/web-app_6_0.xsd
The latest version of Tomcat is 11.0.x, supporting the latest Servlet 6.1 specification, requiring Java 17+.