0

i am trying to learn about servlet from a tutorial I use intellij and this is the structure of the default project project structure

when i try to send a request to the HelloServlet i get this error error

this is the structure of the servlet HelloServlet and this is the pattern of the servlet in web.xml file

<servlet>
    <servlet-name>home</servlet-name>
    <servlet-class>com.example.HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>home</servlet-name>
    <url-pattern>/home</url-pattern>
</servlet-mapping>

the project contain only what I did mention before and this the URL that I am using to request the servlet

http://localhost:8080/demo2_war_exploded/home

also the init() function does not get executed

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • See "javax.servlet.* doesn't work anymore in Servlet 5.0 or newer" section of abovelinked duplicate. – BalusC Dec 19 '22 at 19:42
  • i am not using javax.servlet i am using jakarta.servlet – mohammed djefaflia Dec 19 '22 at 19:48
  • I know. The section contains clues and a link how to correctly use it. It works both ways. javax.servlet doesn't work when you run on server which implements jakarta.servlet or when you blindly put javax.servlet classes in runtime classpath, and from the other side on jakarta.servlet doesn't work when you run on server which implements javax.servlet or when you blindly put jakarta.servlet classes in runtime classpath. See thus the link in that section for an in depth explanation what exactly Tomcat is and how to properly configure pom.xml for it. – BalusC Dec 19 '22 at 20:15

0 Answers0