When I am trying to run this project, I am getting 404 error.But if I run both the servlets independently, they both running fine. ServletContextListener also running fine. Also if I write url http://localhost:8080/servlet_project/startpage then it works fine and execute serv.java
But the problem is in running the whole project. I know their something very little I am missing, (may be my project is not getting what to show the first page )
could someone please tell me that wrong thing I am doing .
The web.xml file is :
The servlet I am using in this project :
Here is the picture which describing the error and my class hierarchy :
Puspender Tanwar wrote:Also if I write url http://localhost:8080/servlet_project/startpage then it works fine and execute serv.java
So that means the setup of your servlet is correct, otherwise that url would not work.
you should probably define a welcome file as described here. Adding the following code snippet to the web.cml file should execute the servlet servlet.
Hope it helps!
Puspender Tanwar wrote:I just ran the solution you told and that just worked fine .
Glad to hear my provided solution did the trick! for me
Puspender Tanwar wrote:So, Welcome file is must ??
No, it's definitely not a must. Otherwise your project would not have run and a runtime exception would be thrown at startup. If you don't define a welcome file, a default welcome file will be used. Often (or maybe even always), that's index.html. Because you want another welcome file to be used in your project, you must define a welcome file list.
Hope it helps!