• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in running my servlet project (404 error)

 
Puspender Tanwar
Ranch Hand
Posts: 392
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a project name servlet_project and 2 servlet named serv and serv2 (sorry for stupid names).
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 :
servlet problem.png
[Thumbnail for servlet problem.png]
When I am running my project, I am getting this
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you worked through the list in the ServletsFaq for 404 errors?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
Kind regards,
Roel
 
Puspender Tanwar
Ranch Hand
Posts: 392
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote: Adding the following code snippet to the web.cml file should execute the servlet servlet.

I just ran the solution you told and that just worked fine .
Thankyou so much Roel
So, Welcome file is must ??
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
Kind regards,
Roel
 
Puspender Tanwar
Ranch Hand
Posts: 392
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok
Thanks One again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic