Failed to create servlet inside maven project

I created a maven project using the - maven-archetype-webapp in the Eclipse IDE.

I managed to create and execute index.jsp, but now I need to create a new servlet. But when I right-click the project and select the new servlet (New-> Other-> Web-> Servlet), I do not see my maven project in the drop-down list, so I can not create the servlet using the Eclipse IDE in my Maven project.

Can someone indicate why this is happening. I am new to Maven.

Thanks,

Edit - My web.xml

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 
+4
source share
1 answer

IF you cannot create a servlet from the menu. Check the following.

  • Check if the Web.xml maven file is created in the WEB-INF folder.
    If not create it.

  • Is the project displayed as a web project or not?
    Right-click Project-> Properties-> Project Boundaries-> Check if the dynamic web module is working or not.? Select it to create a project as a web project.

+5
source

All Articles